Skip to content

Commit a2b01a4

Browse files
committed
set ruff checks more explicit on items
1 parent d3d22de commit a2b01a4

20 files changed

Lines changed: 130 additions & 123 deletions

pyproject.toml

Lines changed: 70 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -97,78 +97,80 @@
9797

9898
[tool.ruff.lint]
9999
select = [
100-
"AIR",
101-
"FAST",
102-
"YTT",
103-
"ASYNC",
104-
"S1", "S2", "S302", "S303", "S304", "S305", "S306", "S307", "S31", "S32", "S401", "S402", "S406", "S407", "S408", "S409", "S41", "S5", "S601", "S602", "S604", "S605", "S606", "S607", "S609", "S61", "S7",
105-
"FBT",
106-
"B00", "B01", "B020", "B021", "B022", "B023", "B025", "B027", "B028", "B029", "B03", "B901", "B903", "B905", "B911",
107-
"A",
108-
"COM",
109-
"C4",
110-
"DTZ003", "DTZ004", "DTZ012", "DTZ901",
111-
"T10",
112-
"DJ003", "DJ01",
113-
"EM",
114-
"EXE",
115-
"FIX",
116-
"FA",
117-
"INT",
118-
"ISC",
119-
"ICN",
120-
"LOG",
121-
"G001", "G002", "G01", "G1", "G2",
122-
"INP",
123-
"PIE",
124-
"T20",
125-
"PYI",
126-
"PT",
127-
"Q",
128-
"RSE",
129-
"RET",
130-
"SIM",
131-
"SLOT",
132-
"TID",
133-
"TD001", "TD004", "TD005", "TD007",
134-
"TC",
135-
"ARG003", "ARG004", "ARG005",
136-
"PTH",
137-
"FLY",
138-
"I",
139-
"C90",
140-
"NPY",
141-
"PD",
142-
"N803", "N804", "N805", "N811", "N812", "N813", "N814", "N817", "N818", "N999",
143-
"PERF1", "PERF2", "PERF401",
144-
"E",
145-
"W",
146-
"DOC202", "DOC403", "DOC502",
147-
"D2", "D3", "D402", "D403", "D405", "D406", "D407", "D408", "D409", "D410", "D411", "D412", "D413", "D414", "D416",
148-
"F",
149-
"PGH",
150-
"PLC",
151-
"PLE",
152-
"PLR01", "PLR02", "PLR04", "PLR0915", "PLR1711", "PLR1704", "PLR1714", "PLR1716", "PLR172", "PLR173", "PLR2044", "PLR5", "PLR6104", "PLR6201",
153-
"PLW",
154-
"UP",
155-
"FURB",
156-
"RUF",
157-
"TRY003", "TRY004", "TRY2", "TRY300", "TRY401",
100+
"A",
101+
"AIR",
102+
"ARG",
103+
"ASYNC",
104+
"B",
105+
"C",
106+
"COM",
107+
"D",
108+
"DJ",
109+
"DOC",
110+
"DTZ",
111+
"E",
112+
"EM",
113+
"EXE",
114+
"F",
115+
"FA",
116+
"FAST",
117+
"FBT",
118+
"FIX",
119+
"FLY",
120+
"FURB",
121+
"G",
122+
"I",
123+
"ICN",
124+
"INP",
125+
"INT",
126+
"ISC",
127+
"LOG",
128+
"N",
129+
"NPY",
130+
"PD",
131+
"PERF",
132+
"PGH",
133+
"PIE",
134+
"PLC",
135+
"PLE",
136+
"PLR",
137+
"PLW",
138+
"PT",
139+
"PTH",
140+
"PYI",
141+
"Q",
142+
"RET",
143+
"RSE",
144+
"RUF",
145+
"S",
146+
"SIM",
147+
"SLOT",
148+
"T",
149+
"TC",
150+
"TD",
151+
"TID",
152+
"TRY",
153+
"UP",
154+
"W",
155+
"YTT",
158156
]
159157

160158
ignore = [
161159
# ignore for now:
162-
"S101", "N803", "N999", "PLR6201",
163-
"S602", "FBT002", "FBT001", "RUF001", "N812", "PLW0603", "PLW0602",
164-
"PLW2901", "PIE810", "PERF203", "FIX004", "N818",
165-
"RUF067",
166-
# end for now.
167-
"COM812", "D203",
168-
"T201", # print statements are ok
169-
"SIM102",
170-
"RUF012",
171-
"D205",
160+
"ARG002","ARG001",
161+
"COM812",
162+
"D107","D102","D101","D103","D100","D105","D104","D205","D203",
163+
"FBT002","FBT001",
164+
"FIX004",
165+
"N812","N818","N806","N802","N815","N816","N803","N999",
166+
"PIE810",
167+
"PLR6201","PLR2004","PLR0917","PLR0913","PLR0911","PLR0912","PLR0914",
168+
"PLW0603","PLW0602", "PLW2901",
169+
"RUF001","RUF067", "RUF012",
170+
"S101","S602",
171+
172+
#
173+
"T201", # print statements are ok, used in verbose mode
172174
"FIX002", # TODOs need some love but we will probably not get of them
173175
"D212", # `multi-line-summary-first-line` (D212) and `multi-line-summary-second-line` (D213) are incompatible.
174176
"PT028", # experimental rule, incomplete

t2.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import logging
22

33
import whoisdomain
4-
from whois_rdap import WhoisRdap
54

65
logger = logging.getLogger(__name__)
76

7+
88
def xmain() -> None:
99
rr = {}
1010

@@ -13,7 +13,7 @@ def xmain() -> None:
1313
level=logging.WARNING,
1414
)
1515

16-
wr = WhoisRdap()
16+
wr = whoisdomain.WhoisRdap()
1717
for k, v in whoisdomain.ZZ.items():
1818
server = v.get("_server")
1919
test = v.get("_test")
@@ -23,18 +23,20 @@ def xmain() -> None:
2323
print("##", k, server, test)
2424

2525
xfld = wr.fld(server)
26+
2627
if xfld not in rr:
2728
dd = wr.do_one_domain(server)
2829
rr[xfld] = dd.data if dd.status else dd.message
2930
if rr[xfld]:
3031
print("Server:", server, xfld, rr[xfld])
3132
if dd.status:
32-
print(wr.map_data_to_whoisdomain(dd.data, with_rdap_whois=True))
33+
print(wr.map_data_to_whoisdomain(dd.data, with_rdap_whois=False))
34+
3335
if test and test != xfld:
3436
dd = wr.do_one_domain(test)
3537
print("Test:", test, dd.data if dd.status else dd.message)
3638
if dd.status:
37-
print(wr.map_data_to_whoisdomain(dd.data, with_rdap_whois=True))
39+
print(wr.map_data_to_whoisdomain(dd.data, with_rdap_whois=False))
3840

3941

4042
xmain()

whoisdomain/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# pylint: disable=duplicate-code
22
"""
3-
Module providing all public accessible functions and data for the whoisdomain package
3+
Module providing all public accessible functions and data for the whoisdomain package.
44
55
## optional modules supported:
66
@@ -53,6 +53,7 @@
5353
from .tldDb.tld_regexpr import ZZ
5454
from .tldInfo import TldInfo
5555
from .version import VERSION
56+
from .whois_rdap import WhoisRdap
5657
from .whoisCliInterface import WhoisCliInterface
5758
from .whoisParser import WhoisParser
5859

@@ -110,6 +111,7 @@
110111
"WhoisCommandTimeout",
111112
"WhoisPrivateRegistry",
112113
"WhoisQuotaExceeded",
114+
"WhoisRdap",
113115
"cleanupWhoisResponse",
114116
"filterTldToSupportedPattern",
115117
"getTestHint",

whoisdomain/cache/dummyCache.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ def __init__(
1212
) -> None:
1313
self.verbose = verbose
1414

15-
def get(
15+
def get( # noqa: PLR6301
1616
self,
1717
keyString: str,
1818
) -> str | None:
1919
return None
2020

21-
def put(
21+
def put( # noqa: PLR6301
2222
self,
2323
keyString: str,
2424
data: str,

whoisdomain/cache/simpleCacheWithFile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def _fileLoad(
3737
self.memCache = json.load(f)
3838
except ValueError as e:
3939
msg = f"ignore json load err: {e}"
40-
log.error(msg)
40+
log.exception(msg)
4141

4242
def _fileSave(
4343
self,

whoisdomain/context/parameterContext.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,9 @@ def _addArgs(
192192
if name in mandatory:
193193
del mandatory[mandatory.index(name)]
194194

195+
@classmethod
195196
def _validateAllMandatoryNowKnown(
196-
self,
197+
cls,
197198
mandatory: list[str],
198199
) -> None:
199200
if len(mandatory) != 0:

whoisdomain/doWhoisCommand.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ def _initDefaultCache(
5555
return CACHE_STUB
5656

5757

58-
# TODO: future: can we use decorator for caching?
5958
def doWhoisAndReturnString(
6059
pc: ParameterContext,
6160
dc: DataContext,

whoisdomain/domain.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Domain:
1717
# The docstrings for classes should summarize its behavior
1818
# and list the public methods and instance variables.
1919
"""
20-
A class to represent a standarized result of a whois lookup
20+
A class to represent a standarized result of a whois lookup.
2121
2222
# Attributes
2323
* Attributes are created dynamically,
@@ -46,8 +46,9 @@ def init(pc: ParameterContext,dc: DataContext) -> None:
4646
4747
"""
4848

49+
@classmethod
4950
def _cleanupArray(
50-
self,
51+
cls,
5152
data: list[str],
5253
) -> list[str]:
5354
if "" in data:
@@ -83,7 +84,11 @@ def _doNameservers(
8384

8485
self.name_servers = sorted(self.name_servers)
8586

86-
def cleanStatus(self, item: str) -> str:
87+
@classmethod
88+
def cleanStatus(
89+
cls,
90+
item: str,
91+
) -> str:
8792
if "icann.org/epp#" in item:
8893
res = re.split(r"\s*\(?https?://(www\.)?icann\.org/epp#\s*", item)
8994
if res and res[0]:

whoisdomain/handleDateStrings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
This module isolates all date parsing in one place
2+
Isolates all date parsing in one place.
33
44
str_to_date() is the only entry point
55
"""
@@ -132,8 +132,8 @@ def str_to_date(
132132

133133
for f in _DATE_FORMATS:
134134
try:
135-
z = datetime.datetime.strptime(text, f)
136-
except ValueError as v:
135+
z = datetime.datetime.strptime(text, f) # noqa: DTZ007
136+
except ValueError as v: # noqa: PERF203
137137
_ = v
138138
else:
139139
return z.astimezone().replace(tzinfo=None)

0 commit comments

Comments
 (0)