Skip to content

Commit 57f5621

Browse files
Account for current flake8 errors with noqa.
- Ignore need for docstrings in function overloads. - Ignore a line being too long due to a pyright: ignore + explanation. - Moving the explanation away from that line doesn't make the line short enough to pass. Removing the error code as well would be enough, but removing both has 2 downsides: a) The lack of explanation on the same line makes it harder to immediately see why the pyright: ignore was added when grepping. b) Having an unrestricted pyright: ignore (or type: ignore) can cover up other typechecking errors, which could cause a problem down the line. - Having a pyright: ignore, a noqa, and fmt: off/on for this one line isn't clean, but I'd like a second opinion on how to handle it.
1 parent 8cff806 commit 57f5621

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

src/rfc3986/compat.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121

2222

2323
@t.overload
24-
def to_str(b: t.Union[str, bytes], encoding: str = "utf-8") -> str:
25-
...
24+
def to_str( # noqa: D103
25+
b: t.Union[str, bytes],
26+
encoding: str = "utf-8",
27+
) -> str: ...
2628

2729

2830
@t.overload
29-
def to_str(b: None, encoding: str = "utf-8") -> None:
31+
def to_str(b: None, encoding: str = "utf-8") -> None: # noqa: D103
3032
...
3133

3234

@@ -41,12 +43,14 @@ def to_str(
4143

4244

4345
@t.overload
44-
def to_bytes(s: t.Union[str, bytes], encoding: str = "utf-8") -> bytes:
45-
...
46+
def to_bytes( # noqa: D103
47+
s: t.Union[str, bytes],
48+
encoding: str = "utf-8",
49+
) -> bytes: ...
4650

4751

4852
@t.overload
49-
def to_bytes(s: None, encoding: str = "utf-8") -> None:
53+
def to_bytes(s: None, encoding: str = "utf-8") -> None: # noqa: D103
5054
...
5155

5256

src/rfc3986/normalizers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,12 @@ def remove_dot_segments(s: str) -> str:
146146

147147

148148
@t.overload
149-
def encode_component(uri_component: None, encoding: str) -> None:
149+
def encode_component(uri_component: None, encoding: str) -> None: # noqa: D103
150150
...
151151

152152

153153
@t.overload
154-
def encode_component(uri_component: str, encoding: str) -> str:
154+
def encode_component(uri_component: str, encoding: str) -> str: # noqa: D103
155155
...
156156

157157

src/rfc3986/validators.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,9 @@ def subauthority_component_is_valid(
435435
return True
436436

437437
try:
438-
port = int(
439-
subauthority_dict["port"]
440-
) # pyright: ignore[reportArgumentType] # Guarded by "except TypeError".
438+
# fmt: off
439+
port = int(subauthority_dict["port"]) # pyright: ignore[reportArgumentType] # noqa: E501 # Guarded by "except TypeError".
440+
# fmt: on
441441
except TypeError:
442442
# If the port wasn't provided it'll be None and int(None) raises a
443443
# TypeError

0 commit comments

Comments
 (0)