gh-983: fix some tying ignore comments#1094
Open
paddyroddy wants to merge 8 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces ty suppression usage by replacing several # ty: ignore[...] comments with explicit typing.cast(...) calls, and standardizes type-checking imports by using import typing + typing.TYPE_CHECKING across modules and tests.
Changes:
- Replaced many
from typing import TYPE_CHECKINGimports withimport typingand updated guards toif typing.TYPE_CHECKING:. - Converted several
# ty: ignore[invalid-*-type]suppressions intotyping.cast(...)at return/yield sites. - Updated
tests/core/test_lensing.pyto avoid ano-matching-overloadignore by callingfrom_convergencewith explicit boolean flags.
Reviewed changes
Copilot reviewed 47 out of 47 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/fixtures/helper_classes.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| tests/fixtures/generators.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| tests/fixtures/domain.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| tests/fixtures/array_backends.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| tests/core/test_user.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| tests/core/test_shells.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| tests/core/test_shapes.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| tests/core/test_points.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| tests/core/test_observations.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| tests/core/test_lensing.py | Switch to import typing guard; remove overload-ignore by passing explicit flags to from_convergence. |
| tests/core/test_healpix.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| tests/core/test_harmonics.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| tests/core/test_galaxies.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| tests/core/test_fields.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| tests/core/test_arraytools.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| tests/core/test_algorithm.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| tests/core/grf/test_transformations.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| tests/core/grf/test_solver.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| tests/core/grf/test_core.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| tests/benchmarks/test_shells.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| tests/benchmarks/test_shapes.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| tests/benchmarks/test_points.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| tests/benchmarks/test_lensing.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| tests/benchmarks/test_harmonics.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| tests/benchmarks/test_galaxies.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| tests/benchmarks/test_fields.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| tests/benchmarks/test_arraytools.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| glass/user.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| glass/shells.py | Switch to import typing / guard; replace invalid-return ignore with typing.cast on restrict() return values. |
| glass/shapes.py | Switch to import typing / guard; replace invalid-return ignores with typing.cast for ComplexArray returns. |
| glass/points.py | Switch to import typing / guard while keeping Any import; update TYPE_CHECKING usage. |
| glass/observations.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| glass/lensing.py | Switch to import typing / guard; use @typing.overload; replace invalid-return ignore with typing.cast in multi_plane_matrix. |
| glass/jax.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| glass/healpix.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| glass/harmonics.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| glass/grf/_transformations.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| glass/grf/_solver.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| glass/grf/_core.py | Switch to import typing / guard; replace Protocol import usage with typing.Protocol. |
| glass/galaxies.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| glass/fields.py | Switch to import typing / guard; replace invalid-yield/return ignores with typing.cast; update nested TYPE_CHECKING usage. |
| glass/cosmology.py | Replace Protocol import usage with typing.Protocol. |
| glass/arraytools.py | Switch to import typing / guard; replace invalid-assignment ignore with typing.cast around xpx.union1d. |
| glass/algorithm.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| glass/_types.py | Switch to import typing / guard; use typing.ParamSpec / typing.TypeVar in TYPE_CHECKING block. |
| glass/_rng.py | Switch to import typing and typing.TYPE_CHECKING guard. |
| glass/_array_api_utils.py | Switch to import typing / guard; move Any import under TYPE_CHECKING. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Tidying up
ty: ignorecomments where possible. Have also been more consistent of when we do and don't usefrom typing importsyntax.Closes: #983, #1071
Checks