Skip to content

gh-983: fix some typing ignores, sort fixtures, tidy typing - #1095

Merged
paddyroddy merged 14 commits into
mainfrom
paddy/issue-983
Jun 2, 2026
Merged

gh-983: fix some typing ignores, sort fixtures, tidy typing#1095
paddyroddy merged 14 commits into
mainfrom
paddy/issue-983

Conversation

@paddyroddy

@paddyroddy paddyroddy commented Jun 1, 2026

Copy link
Copy Markdown
Member

Description

Reattempt at #1094. Tidying up some ty: ignore statements. Sorting fixtures alphabetically and fix the missing type[] typing.. Also be more selective on from typing import <x>.

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 requested a review from Copilot June 1, 2026 15:18
@paddyroddy paddyroddy self-assigned this Jun 1, 2026
@paddyroddy
paddyroddy marked this pull request as ready for review June 1, 2026 15:18
@paddyroddy paddyroddy added enhancement New feature or request maintenance Maintenance: refactoring, typos, etc. typing Static typing labels Jun 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 focuses on reducing/cleaning ty suppressions and tightening typing across the library and its test suite, while also applying small formatting/consistency updates (e.g., fixture typing and line wrapping). It also updates coverage configuration patterns to account for typing.-qualified typing constructs.

Changes:

  • Replaced several ty: ignore[...] return-type suppressions with explicit typing.cast(...) in core modules.
  • Updated typing imports to be more selective/consistent (favoring import typing + typing.Protocol / typing.overload patterns).
  • Tidied tests/benchmarks: fixture parameter annotations (type[...]) and consistent formatting/wrapping; updated coverage exclude regexes.

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/fixtures/helper_classes.py Minor formatting tweak in helper fixture class generation.
tests/core/test_user.py Formatting-only wrap for readability/consistency.
tests/core/test_shells.py Formatting-only wraps for test function signatures.
tests/core/test_shapes.py Formatting-only wraps for test function signatures.
tests/core/test_points.py Correct fixture type annotations (type[...]) and signature formatting.
tests/core/test_observations.py Formatting-only wraps for test function signatures.
tests/core/test_lensing.py Removes a now-unnecessary ty: ignore after overload typing improvements.
tests/core/test_harmonics.py Formatting-only wraps for test function signatures.
tests/core/test_galaxies.py Formatting-only wraps for test function signatures.
tests/core/test_fields.py Formatting-only wraps plus minor assertion formatting.
tests/core/test_arraytools.py Formatting-only wraps for test function signatures.
tests/core/test_algorithm.py Formatting-only wraps for test function signatures.
tests/core/grf/test_transformations.py Formatting-only wraps for test function signatures.
tests/core/grf/test_solver.py Formatting-only wraps for test function signatures.
tests/core/grf/test_core.py Formatting-only wraps for test function signatures.
tests/benchmarks/test_shells.py Fixes benchmark fixture parameter annotation to type[Compare].
tests/benchmarks/test_points.py Fixes benchmark fixture parameter annotations to type[...].
tests/benchmarks/test_fields.py Fixes benchmark fixture parameter annotations to type[...].
pyproject.toml Updates coverage exclusion regexes for typing.-qualified constructs.
glass/shells.py Replaces invalid-return-type ignore with explicit casts; adds import typing.
glass/shapes.py Casts ellipticity outputs to ComplexArray; adds import typing.
glass/points.py Moves Any import under TYPE_CHECKING and removes an unnecessary local annotation.
glass/lensing.py Switches to typing.overload and casts; adjusts overload defaults for the all-False case.
glass/grf/_core.py Uses typing.Protocol instead of importing Protocol directly.
glass/galaxies.py Formatting-only change (trailing comma / wrapping).
glass/fields.py Replaces return-type ignore(s) with casts; adds import typing; small formatting wrap.
glass/ext/init.py Removes an unnecessary ty: ignore by simplifying return expression.
glass/cosmology.py Uses typing.Protocol instead of importing Protocol directly.
glass/arraytools.py Replaces an assignment ignore with an explicit cast around xpx.union1d.
glass/_types.py Uses typing.ParamSpec/typing.TypeVar (via import typing) under TYPE_CHECKING.
glass/_array_api_utils.py Moves Any import under TYPE_CHECKING to reduce runtime typing imports.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@paddyroddy
paddyroddy requested a review from connoraird June 1, 2026 15:24

@connoraird connoraird left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's a shame we have to call typing stuff in the actual function bodies but I guess it's worth it.

@paddyroddy paddyroddy mentioned this pull request Jun 2, 2026
5 tasks
@paddyroddy

Copy link
Copy Markdown
Member Author

It's a shame we have to call typing stuff in the actual function bodies but I guess it's worth it.

Yeah, it's weird, haven't done it before. But this feels like a better (temporary) fix rather than just suppressing all errors with a # ty: ignore[] comment.

@paddyroddy
paddyroddy merged commit 3162211 into main Jun 2, 2026
11 of 13 checks passed
@paddyroddy
paddyroddy deleted the paddy/issue-983 branch June 2, 2026 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Following #926 try to fix some ty errors

3 participants