Skip to content

Commit 5ea5a15

Browse files
committed
Some who-knows-if-exactly-correct type thrashing for newer pyright.
Refs: microsoft/pyright#9190 (comment)
1 parent 0f546ba commit 5ea5a15

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def typing(session):
9898
"""
9999
Check static typing.
100100
"""
101-
session.install("pyright<1.1.354", ROOT)
101+
session.install("pyright", ROOT)
102102
session.run("pyright", *session.posargs, REFERENCING)
103103

104104

referencing/_core.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,8 @@ def combine(self, *registries: Registry[D]) -> Registry[D]:
557557
anchors = anchors.update(registry._anchors)
558558
uncrawled = uncrawled.update(registry._uncrawled)
559559

560-
if registry._retrieve is not _fail_to_retrieve:
561-
if registry._retrieve is not retrieve is not _fail_to_retrieve:
560+
if registry._retrieve is not _fail_to_retrieve: # type: ignore[reportUnnecessaryComparison] ???
561+
if registry._retrieve is not retrieve is not _fail_to_retrieve: # type: ignore[reportUnnecessaryComparison] ???
562562
raise ValueError( # noqa: TRY003
563563
"Cannot combine registries with conflicting retrieval "
564564
"functions.",
@@ -590,7 +590,11 @@ def resolver_with_root(self, resource: Resource[D]) -> Resolver[D]:
590590

591591

592592
#: An anchor or resource.
593-
AnchorOrResource = TypeVar("AnchorOrResource", AnchorType[Any], Resource[Any])
593+
AnchorOrResource = TypeVar(
594+
"AnchorOrResource",
595+
bound=AnchorType[Any] | Resource[Any],
596+
default=AnchorType[Any] | Resource[Any],
597+
)
594598

595599

596600
@frozen

referencing/jsonschema.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ def maybe_in_subresource(
435435
"properties",
436436
},
437437
),
438-
anchors_in=_anchor_2019, # type: ignore[reportGeneralTypeIssues] # TODO: check whether this is real
438+
anchors_in=_anchor_2019,
439439
maybe_in_subresource=_maybe_in_subresource_crazy_items(
440440
in_value={
441441
"additionalItems",
@@ -478,7 +478,7 @@ def maybe_in_subresource(
478478
in_subarray={"allOf", "anyOf", "oneOf"},
479479
in_subvalues={"definitions", "patternProperties", "properties"},
480480
),
481-
anchors_in=_legacy_anchor_in_dollar_id, # type: ignore[reportGeneralTypeIssues] # TODO: check whether this is real
481+
anchors_in=_legacy_anchor_in_dollar_id,
482482
maybe_in_subresource=_maybe_in_subresource_crazy_items_dependencies(
483483
in_value={
484484
"additionalItems",
@@ -509,7 +509,7 @@ def maybe_in_subresource(
509509
in_subarray={"allOf", "anyOf", "oneOf"},
510510
in_subvalues={"definitions", "patternProperties", "properties"},
511511
),
512-
anchors_in=_legacy_anchor_in_dollar_id, # type: ignore[reportGeneralTypeIssues] # TODO: check whether this is real
512+
anchors_in=_legacy_anchor_in_dollar_id,
513513
maybe_in_subresource=_maybe_in_subresource_crazy_items_dependencies(
514514
in_value={
515515
"additionalItems",
@@ -556,7 +556,7 @@ def maybe_in_subresource(
556556

557557

558558
_SPECIFICATIONS: Registry[Specification[Schema]] = Registry(
559-
{ # type: ignore[reportGeneralTypeIssues] # :/ internal vs external types
559+
{
560560
dialect_id: Resource.opaque(specification)
561561
for dialect_id, specification in [
562562
("https://json-schema.org/draft/2020-12/schema", DRAFT202012),

referencing/retrieval.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from referencing.typing import URI, D, Retrieve
1515

1616
#: A serialized document (e.g. a JSON string)
17-
_T = TypeVar("_T")
17+
_T = TypeVar("_T", default=str)
1818

1919

2020
def to_cached_resource(

referencing/typing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from __future__ import annotations
66

77
from collections.abc import Mapping as Mapping
8-
from typing import TYPE_CHECKING, Protocol, TypeVar
8+
from typing import TYPE_CHECKING, Any, Protocol, TypeVar
99

1010
if TYPE_CHECKING:
1111
from referencing._core import Resolved, Resolver, Resource
@@ -14,7 +14,7 @@
1414
URI = str
1515

1616
#: The type of documents within a registry.
17-
D = TypeVar("D")
17+
D = TypeVar("D", default=Any)
1818

1919

2020
class Retrieve(Protocol[D]):

0 commit comments

Comments
 (0)