Skip to content

Commit 9e812f3

Browse files
Made minor adjustments to a few annotations.
- Made int | str order consistent. - The ParseResultMixin shim properties are now marked with t.Optional, since what they wrap can be None.
1 parent 3969c1d commit 9e812f3

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/rfc3986/builder.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def add_host(self, host: str) -> "URIBuilder":
188188
fragment=self.fragment,
189189
)
190190

191-
def add_port(self, port: t.Union[str, int]) -> "URIBuilder":
191+
def add_port(self, port: t.Union[int, str]) -> "URIBuilder":
192192
"""Add port to the URI.
193193
194194
.. code-block:: python

src/rfc3986/parseresult.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,17 @@ def geturl(self) -> t.AnyStr:
6464
return self.unsplit()
6565

6666
@property
67-
def hostname(self) -> t.AnyStr:
67+
def hostname(self) -> t.Optional[t.AnyStr]:
6868
"""Shim to match the standard library."""
6969
return self.host
7070

7171
@property
72-
def netloc(self) -> t.AnyStr:
72+
def netloc(self) -> t.Optional[t.AnyStr]:
7373
"""Shim to match the standard library."""
7474
return self.authority
7575

7676
@property
77-
def params(self) -> t.AnyStr:
77+
def params(self) -> t.Optional[t.AnyStr]:
7878
"""Shim to match the standard library."""
7979
return self.query
8080

@@ -210,7 +210,7 @@ def copy_with(
210210
scheme: t.Optional[str] = misc.UseExisting,
211211
userinfo: t.Optional[str] = misc.UseExisting,
212212
host: t.Optional[str] = misc.UseExisting,
213-
port: t.Optional[str] = misc.UseExisting,
213+
port: t.Optional[t.Union[int, str]] = misc.UseExisting,
214214
path: t.Optional[str] = misc.UseExisting,
215215
query: t.Optional[str] = misc.UseExisting,
216216
fragment: t.Optional[str] = misc.UseExisting,
@@ -316,7 +316,7 @@ def from_parts(
316316
scheme: t.Optional[str] = None,
317317
userinfo: t.Optional[str] = None,
318318
host: t.Optional[str] = None,
319-
port: t.Optional[t.Union[str, int]] = None,
319+
port: t.Optional[t.Union[int, str]] = None,
320320
path: t.Optional[str] = None,
321321
query: t.Optional[str] = None,
322322
fragment: t.Optional[str] = None,

0 commit comments

Comments
 (0)