-
Notifications
You must be signed in to change notification settings - Fork 55
fix[next]: Reduce type ignores in client code #2484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
906254f
28fdaa2
8681dec
3964075
9854f2b
7b1ed38
e0e6c9f
02bc14d
ef038b8
bcb960e
d7bb4a8
d56ce33
e9fdf85
a0db128
4c252e8
da6aaf0
b9cce17
383a8e8
fa995be
564f98c
3f55492
d48e307
415a435
c9ac562
71ab1e1
fc84bb0
ed42283
82d25be
4e2a08e
e29bff0
b9a2fde
5428507
725f3cc
7399d4e
fc0911f
456bf81
abb72ca
17d5eef
a529bbc
34ed14a
1180628
043c2be
5216972
264fef6
bf2f7aa
065ea19
cec6dcc
239ac13
2e1422e
9889ed0
da20631
e527c29
b3b2eac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,3 +40,24 @@ jobs: | |
|
|
||
| - name: "Run pre-commit" | ||
| uses: pre-commit/[email protected] | ||
|
|
||
| typing-exports: | ||
| needs: [get-python-versions] | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: ${{ fromJSON(needs.get-python-versions.outputs.python-versions) }} | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v7 | ||
| with: | ||
| enable-cache: true | ||
| cache-dependency-glob: "uv.lock" | ||
|
|
||
| - name: "Run typing checks on exported entities" | ||
| run: | | ||
| ./noxfile.py -s 'test_typing_exports-${{ fromJson(needs.get-python-versions.outputs.python-versions) }}' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,6 +109,28 @@ def __sub__(self, offset: int) -> Connectivity: | |
| return self + (-offset) | ||
|
|
||
|
|
||
| if TYPE_CHECKING: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a question: since this is only used in the mypy plugin, would it be possible to move these definitions into the the plugin module?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried that first, but it seems the type has to be reachable from the context that is being checked. The only safe place for it is in the same module that defines |
||
| # These exist as on-the fly replacements for Dimension instances | ||
| # (which are not types) during typechecking (with mypy). We can | ||
| # track up to four distinct dimensions at a time, everything beyond | ||
| # becomes AnyDim | ||
|
|
||
| @dataclasses.dataclass(frozen=True) | ||
| class _DimA(Dimension): ... | ||
|
|
||
| @dataclasses.dataclass(frozen=True) | ||
| class _DimB(Dimension): ... | ||
|
|
||
| @dataclasses.dataclass(frozen=True) | ||
| class _DimC(Dimension): ... | ||
|
|
||
| @dataclasses.dataclass(frozen=True) | ||
| class _DimD(Dimension): ... | ||
|
|
||
| @dataclasses.dataclass(frozen=True) | ||
| class _AnyDim(Dimension): ... | ||
|
|
||
|
|
||
| class Infinity(enum.Enum): | ||
| """Describes an unbounded `UnitRange`.""" | ||
|
|
||
|
|
@@ -772,6 +794,18 @@ def __rtruediv__(self, other: Field | core_defs.ScalarT) -> Field: ... | |
| @abc.abstractmethod | ||
| def __pow__(self, other: Field | core_defs.ScalarT) -> Field: ... | ||
|
|
||
| @abc.abstractmethod | ||
| def __lt__(self, other: Field | core_defs.ScalarT) -> Field[Any, bool]: ... | ||
|
|
||
| @abc.abstractmethod | ||
| def __le__(self, other: Field | core_defs.ScalarT) -> Field[Any, bool]: ... | ||
|
|
||
| @abc.abstractmethod | ||
| def __gt__(self, other: Field | core_defs.ScalarT) -> Field[Any, bool]: ... | ||
|
|
||
| @abc.abstractmethod | ||
| def __ge__(self, other: Field | core_defs.ScalarT) -> Field[Any, bool]: ... | ||
|
|
||
DropD marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @abc.abstractmethod | ||
| def __and__(self, other: Field | core_defs.ScalarT) -> Field: | ||
| """Only defined for `Field` of value type `bool`.""" | ||
|
|
@@ -994,36 +1028,48 @@ def __ne__(self, other: Any) -> Never: | |
| def __add__(self, other: Field | core_defs.IntegralScalar) -> Never: | ||
| raise TypeError("'Connectivity' does not support this operation.") | ||
|
|
||
| def __radd__(self, other: Field | core_defs.IntegralScalar) -> Never: # type: ignore[misc] # Forward operator not callalbe | ||
| def __radd__(self, other: Field | core_defs.IntegralScalar) -> Never: | ||
| raise TypeError("'Connectivity' does not support this operation.") | ||
|
|
||
| def __sub__(self, other: Field | core_defs.IntegralScalar) -> Never: | ||
| raise TypeError("'Connectivity' does not support this operation.") | ||
|
|
||
| def __rsub__(self, other: Field | core_defs.IntegralScalar) -> Never: # type: ignore[misc] # Forward operator not callalbe | ||
| def __rsub__(self, other: Field | core_defs.IntegralScalar) -> Never: | ||
| raise TypeError("'Connectivity' does not support this operation.") | ||
|
|
||
| def __mul__(self, other: Field | core_defs.IntegralScalar) -> Never: | ||
| raise TypeError("'Connectivity' does not support this operation.") | ||
|
|
||
| def __rmul__(self, other: Field | core_defs.IntegralScalar) -> Never: # type: ignore[misc] # Forward operator not callalbe | ||
| def __rmul__(self, other: Field | core_defs.IntegralScalar) -> Never: | ||
| raise TypeError("'Connectivity' does not support this operation.") | ||
|
|
||
| def __truediv__(self, other: Field | core_defs.IntegralScalar) -> Never: | ||
| raise TypeError("'Connectivity' does not support this operation.") | ||
|
|
||
| def __rtruediv__(self, other: Field | core_defs.IntegralScalar) -> Never: # type: ignore[misc] # Forward operator not callalbe | ||
| def __rtruediv__(self, other: Field | core_defs.IntegralScalar) -> Never: | ||
| raise TypeError("'Connectivity' does not support this operation.") | ||
|
|
||
| def __floordiv__(self, other: Field | core_defs.IntegralScalar) -> Never: | ||
| raise TypeError("'Connectivity' does not support this operation.") | ||
|
|
||
| def __rfloordiv__(self, other: Field | core_defs.IntegralScalar) -> Never: # type: ignore[misc] # Forward operator not callalbe | ||
| def __rfloordiv__(self, other: Field | core_defs.IntegralScalar) -> Never: | ||
| raise TypeError("'Connectivity' does not support this operation.") | ||
|
|
||
| def __pow__(self, other: Field | core_defs.IntegralScalar) -> Never: | ||
| raise TypeError("'Connectivity' does not support this operation.") | ||
|
|
||
| def __lt__(self, other: Field | core_defs.IntegralScalar) -> Never: | ||
| raise TypeError("'Connectivity' does not support this operation.") | ||
|
|
||
| def __le__(self, other: Field | core_defs.IntegralScalar) -> Never: | ||
| raise TypeError("'Connectivity' does not support this operation.") | ||
|
|
||
| def __gt__(self, other: Field | core_defs.IntegralScalar) -> Never: | ||
| raise TypeError("'Connectivity' does not support this operation.") | ||
|
|
||
| def __ge__(self, other: Field | core_defs.IntegralScalar) -> Never: | ||
| raise TypeError("'Connectivity' does not support this operation.") | ||
|
|
||
| def __and__(self, other: Field | core_defs.IntegralScalar) -> Never: | ||
| raise TypeError("'Connectivity' does not support this operation.") | ||
|
|
||
|
|
@@ -1205,7 +1251,7 @@ def __gt_origin__(self) -> Never: | |
|
|
||
| @property | ||
| def dtype(self) -> core_defs.DType[core_defs.IntegralScalar]: | ||
| return core_defs.Int32DType() # type: ignore[return-value] | ||
| return core_defs.Int32DType() | ||
|
|
||
| # This is a workaround to make this class concrete, since `codomain` is an | ||
| # abstract property of the `Connectivity` Protocol. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.