Skip to content

Commit c7ab1db

Browse files
Annotate misc.get_path() while breaking an import cycle.
- `uri` can't be eagerly imported within `misc` without causing a circular import, but is necessary for getting the most currently correct parameter type.
1 parent f305405 commit c7ab1db

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/rfc3986/misc.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@
1818
expressions for parsing and validating URIs and their components.
1919
"""
2020
import re
21+
import typing as t
2122

2223
from . import abnf_regexp
2324

25+
if t.TYPE_CHECKING:
26+
# Break an import loop.
27+
from . import uri
28+
2429
# These are enumerated for the named tuple used as a superclass of
2530
# URIReference
2631
URI_COMPONENTS = ["scheme", "authority", "path", "query", "fragment"]
@@ -118,7 +123,7 @@
118123

119124

120125
# Path merger as defined in http://tools.ietf.org/html/rfc3986#section-5.2.3
121-
def merge_paths(base_uri, relative_path):
126+
def merge_paths(base_uri: "uri.URIReference", relative_path: str) -> str:
122127
"""Merge a base URI's path with a relative URI's path."""
123128
if base_uri.path is None and base_uri.authority is not None:
124129
return "/" + relative_path

0 commit comments

Comments
 (0)