Skip to content

Commit cfe8921

Browse files
Pre-commit hooks to handle #noqas
Stop blanket #noqas and remove unnecessary ones
1 parent 3796047 commit cfe8921

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+71
-63
lines changed

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,11 @@ repos:
1818
rev: 5.0.4
1919
hooks:
2020
- id: flake8
21+
- repo: https://github.com/asottile/yesqa
22+
rev: v1.5.0
23+
hooks:
24+
- id: yesqa
25+
- repo: https://github.com/pre-commit/pygrep-hooks
26+
rev: v1.9.0
27+
hooks:
28+
- id: python-check-blanket-noqa

cardinal_pythonlib/argparse_func.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class ShowAllSubparserHelpAction(_HelpAction):
5555
shows help for all subparsers. As per
5656
5757
https://stackoverflow.com/questions/20094215/argparse-subparser-monolithic-help-output
58-
""" # noqa: E501
58+
"""
5959

6060
def __call__(
6161
self,
@@ -147,7 +147,7 @@ def str2bool(v: str) -> bool:
147147
default=NICE, # if the argument is entirely absent
148148
help="Activate nice mode.")
149149
150-
""" # noqa: E501
150+
"""
151151
lv = v.lower()
152152
if lv in ("yes", "true", "t", "y", "1"):
153153
return True

cardinal_pythonlib/cmdline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def cmdline_split(s: str, platform: Union[int, str] = "this") -> List[str]:
4848
- ``1`` = POSIX;
4949
- ``0`` = Windows/CMD
5050
- (other values reserved)
51-
""" # noqa: E501
51+
"""
5252
if platform == "this":
5353
platform = sys.platform != "win32" # RNC: includes 64-bit Windows
5454

cardinal_pythonlib/compression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def gzip_string(text: str, encoding: str = "utf-8") -> bytes:
8888
print(gz1 == gz2) # False
8989
# ... but the difference is probably in the timestamp bytes!
9090
91-
""" # noqa: E501
91+
"""
9292
data = text.encode(encoding)
9393
return gzip.compress(data)
9494

cardinal_pythonlib/datetimefunc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def strfdelta(
307307
308308
Modified from
309309
https://stackoverflow.com/questions/538666/python-format-timedelta-to-string
310-
""" # noqa: E501
310+
"""
311311

312312
# Convert tdelta to integer seconds.
313313
if inputtype == "timedelta":
@@ -639,7 +639,7 @@ def duration_to_iso(
639639
realistic (negative, 1000 years, 11 months, and the maximum length for
640640
seconds/microseconds).
641641
642-
""" # noqa: E501
642+
"""
643643
prefix = ""
644644
negative = d < Duration()
645645
if negative and minus_sign_at_front:

cardinal_pythonlib/dicts.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def rename_keys_in_dict(d: Dict[str, Any], renames: Dict[str, str]) -> None:
120120
121121
See
122122
https://stackoverflow.com/questions/4406501/change-the-name-of-a-key-in-dictionary.
123-
""" # noqa: E501
123+
"""
124124
for old_key, new_key in renames.items():
125125
if new_key == old_key:
126126
continue
@@ -257,7 +257,7 @@ class LazyDict(dict):
257257
258258
The ``*args``/``**kwargs`` parts are useful, but we don't want to have to
259259
name 'thunk' explicitly.
260-
""" # noqa: E501
260+
"""
261261

262262
def get(
263263
self, key: Hashable, thunk: Any = None, *args: Any, **kwargs: Any
@@ -292,7 +292,7 @@ class LazyButHonestDict(dict):
292292
Compared to the StackOverflow version: no obvious need to have a default
293293
returning ``None``, when we're implementing this as a special function.
294294
In contrast, helpful to have ``*args``/``**kwargs`` options.
295-
""" # noqa: E501
295+
"""
296296

297297
def lazyget(
298298
self, key: Hashable, thunk: Callable, *args: Any, **kwargs: Any

cardinal_pythonlib/docker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def running_under_docker() -> bool:
3535
As per
3636
https://stackoverflow.com/questions/43878953/how-does-one-detect-if-one-is-running-within-a-docker-container-within-python
3737
... but without leaving a file open.
38-
""" # noqa: E501
38+
"""
3939
# 1. Does /.dockerenv exist?
4040
if os.path.exists("/.dockerenv"):
4141
return True

cardinal_pythonlib/dogpile_cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def get_namespace(fn: Callable, namespace: Optional[str]) -> str:
128128
normally a ``str``; if not ``None``, ``str(namespace)`` will be
129129
added to the result. See
130130
https://dogpilecache.readthedocs.io/en/latest/api.html#dogpile.cache.region.CacheRegion.cache_on_arguments
131-
""" # noqa: E501
131+
"""
132132
# See hidden attributes with dir(fn)
133133
# noinspection PyUnresolvedReferences
134134
return "{module}:{name}{extra}".format(

cardinal_pythonlib/dsp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def normalized_frequency(f: float, sampling_freq: float) -> float:
6565
- e.g. see https://en.wikipedia.org/wiki/Nyquist_frequency,
6666
https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.iirnotch.html
6767
68-
""" # noqa: E501
68+
"""
6969
return f / (sampling_freq / 2.0)
7070

7171

cardinal_pythonlib/email/sendmail.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ def send_email(
462462
https://docs.djangoproject.com/en/2.1/ref/settings/#email-use-ssl). We
463463
don't support that here.
464464
465-
""" # noqa: E501
465+
"""
466466
if isinstance(to, str):
467467
to = [to]
468468
if isinstance(cc, str):
@@ -533,7 +533,7 @@ def is_email_valid(email_: str) -> bool:
533533
534534
See
535535
https://stackoverflow.com/questions/8022530/how-to-check-for-valid-email-address.
536-
""" # noqa: E501
536+
"""
537537
# Very basic checks!
538538
if not email_:
539539
return False

0 commit comments

Comments
 (0)