Skip to content

Commit

Permalink
Annotate misc.get_path() while breaking an import cycle.
Browse files Browse the repository at this point in the history
- `uri` can't be eagerly imported within `misc` without causing a circular import, but is necessary for getting the most currently correct parameter type.
  • Loading branch information
Sachaa-Thanasius committed Jun 15, 2024
1 parent f305405 commit c7ab1db
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/rfc3986/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@
expressions for parsing and validating URIs and their components.
"""
import re
import typing as t

from . import abnf_regexp

if t.TYPE_CHECKING:
# Break an import loop.
from . import uri

# These are enumerated for the named tuple used as a superclass of
# URIReference
URI_COMPONENTS = ["scheme", "authority", "path", "query", "fragment"]
Expand Down Expand Up @@ -118,7 +123,7 @@


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

0 comments on commit c7ab1db

Please sign in to comment.