Skip to content
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

gh-358: add static types support #368

Merged
merged 160 commits into from
Nov 7, 2024
Merged

gh-358: add static types support #368

merged 160 commits into from
Nov 7, 2024

Conversation

paddyroddy
Copy link
Member

@paddyroddy paddyroddy commented Oct 15, 2024

Closes #358. Replaces #308.

This PR adds static type support, hence satisfying mypy. With the adaptation of #67 I anticipate typing to change, but it's much easier to do once mypy is passing initially.

The only # type: ignore[] comments remaining are attr-defined which are all attributed to np.trapz, those can easily be fixed by #207.

I have turned off:

  • disallow_untyped_decorators this is being triggered by pytest and nox. The equivalent # type: ignore[] error is misc which isn't the most informative
  • warn_return_any which is due to external libraries like cosmology - this could be revisited in the future

I have decided to re-write some of the tests which were simply not following the typing - like passing is a list rather than a np.ndarray. The alternative approach would be having really messy typing.

I'm not expecting this to be fully perfect. We will likely have to iterate on this, and completely change once we follow #67. But this is a good first step.

Do make sure to look carefully. Hard to avoid such a big PR with this. There were over 200 # type: ignore[] comments to fix!

Copy link
Member

@Saransh-cpp Saransh-cpp left a comment

Choose a reason for hiding this comment

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

Amazing work 🤯

glass/core/array.py Outdated Show resolved Hide resolved
glass/galaxies.py Outdated Show resolved Hide resolved
glass/galaxies.py Outdated Show resolved Hide resolved
glass/galaxies.py Outdated Show resolved Hide resolved
.git-blame-ignore-revs Outdated Show resolved Hide resolved
Comment on lines -134 to -137
"ANN001", # TODO: missing-type-function-argument
"ANN002", # TODO: missing-type-args
"ANN003", # TODO: missing-type-kwargs
"ANN201", # TODO: missing-return-type-undocumented-public-function
Copy link
Member

Choose a reason for hiding this comment

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

🎉

pyproject.toml Outdated Show resolved Hide resolved
glass/core/array.py Show resolved Hide resolved
glass/lensing.py Outdated Show resolved Hide resolved
glass/lensing.py Outdated Show resolved Hide resolved
glass/lensing.py Outdated Show resolved Hide resolved
glass/lensing.py Outdated Show resolved Hide resolved
glass/shapes.py Outdated Show resolved Hide resolved
glass/shapes.py Outdated Show resolved Hide resolved
glass/shapes.py Outdated Show resolved Hide resolved
glass/user.py Outdated Show resolved Hide resolved
glass/user.py Outdated Show resolved Hide resolved
glass/user.py Outdated Show resolved Hide resolved
@paddyroddy
Copy link
Member Author

paddyroddy commented Nov 6, 2024

@ntessore I've addressed through your comments

Copy link
Collaborator

@ntessore ntessore left a comment

Choose a reason for hiding this comment

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

Fantastic! Well done!

Copy link
Member

@Saransh-cpp Saransh-cpp left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks for putting so much efforts into this, @paddyroddy!

@paddyroddy
Copy link
Member Author

Thanks both for the review. Will merge this and update the downstream PRs.

@paddyroddy paddyroddy merged commit 74c5ac8 into main Nov 7, 2024
16 checks passed
@paddyroddy paddyroddy deleted the paddy/issue-358 branch November 7, 2024 10:32
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.

Add static types
3 participants