Skip to content

gh-983: fix some tying ignore comments#1094

Open
paddyroddy wants to merge 8 commits into
paddy/issue-1076from
paddy/issue-983
Open

gh-983: fix some tying ignore comments#1094
paddyroddy wants to merge 8 commits into
paddy/issue-1076from
paddy/issue-983

Conversation

@paddyroddy
Copy link
Copy Markdown
Member

@paddyroddy paddyroddy commented May 29, 2026

Description

Tidying up ty: ignore comments where possible. Have also been more consistent of when we do and don't use from typing import syntax.

Closes: #983, #1071

Checks

  • Is your code passing linting?
  • Is your code passing tests?
  • Have you added additional tests (if required)?
  • Have you modified/extended the documentation (if required)?
  • Have you added a one-liner changelog entry above (if required)?

@paddyroddy paddyroddy self-assigned this May 29, 2026
@paddyroddy paddyroddy added enhancement New feature or request maintenance Maintenance: refactoring, typos, etc. typing Static typing labels May 29, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_CHECKING imports with import typing and updated guards to if typing.TYPE_CHECKING:.
  • Converted several # ty: ignore[invalid-*-type] suppressions into typing.cast(...) at return/yield sites.
  • Updated tests/core/test_lensing.py to avoid a no-matching-overload ignore by calling from_convergence with 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.

Comment thread glass/fields.py Outdated
Comment thread glass/lensing.py
@paddyroddy paddyroddy marked this pull request as ready for review May 29, 2026 16:35
@paddyroddy paddyroddy added the blocked The issue or pull request is blocked by something label May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked The issue or pull request is blocked by something enhancement New feature or request maintenance Maintenance: refactoring, typos, etc. typing Static typing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants