-
Notifications
You must be signed in to change notification settings - Fork 9
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 and fix (some) mypy
#308
Closed
Closed
Conversation
This file contains 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
paddyroddy
added
enhancement
New feature or request
infrastructure
Project infrastructure: dev tools, packaging, etc.
maintenance
Maintenance: refactoring, typos, etc.
labels
Oct 3, 2024
Add a bunch of typing, proceed to increase the number of errors by 💯 😀 |
This was referenced Oct 4, 2024
This was referenced Oct 9, 2024
Paused in favour of #347 |
paddyroddy
added a commit
that referenced
this pull request
Oct 14, 2024
Closes #346. Working towards #188. The main changes here have been: - Remove all types in the docstrings in favour of proper static typing (being added in #308) - Switch from `numpydoc` to `sphinx.ext.napolean` due to numpy/numpydoc#196 Have had to change the references to `[1]` rather than `[1]_` due to this bug, sphinx-doc/sphinx#9689. Hopefully this can be fixed in the future. Example: `glass.lensing.from_convergence` <img width="781" alt="image" src="https://github.com/user-attachments/assets/9b6fd087-686a-4a5c-a77a-f8a3ec9fc3e2"> Raised #350, #351.
Going to merge and address conflicts from #347 |
Closed
paddyroddy
added a commit
that referenced
this pull request
Oct 14, 2024
Fixes #355, simplifying #308. Change all import of `typing`/`collections.abc` to `import <x>` rather than `from <x> import` syntax. This is useful because it is straightforward to see at a glance where the `import` is coming from. Further, we have both `numpy.random.Generator` and `collections.abc.Generator` in use - so it separates them. I've also moved everything out of the `TYPE_CHECKING` block, except from where `ruff` says we should.
paddyroddy
added a commit
that referenced
this pull request
Oct 14, 2024
Fixes #355, simplifying #308, xref #350. Change all import of `typing`/`collections.abc` to `import <x>` rather than `from <x> import` syntax. This is useful because it is straightforward to see at a glance where the `import` is coming from. Further, we have both `numpy.random.Generator` and `collections.abc.Generator` in use - so it separates them. I've also moved everything out of the `TYPE_CHECKING` block, except from where `ruff` says we should.
paddyroddy
changed the title
gh-280: add
gh-358: add static types and fix (some) Oct 14, 2024
mypy
supportmypy
This was referenced Oct 14, 2024
paddyroddy
added a commit
that referenced
this pull request
Oct 15, 2024
Adding `mypy` to a pre-existing codebase is never easy. I initially attempted this in #308, but have since split this up into separate issues: - [x] #347 - [x] #356 - [ ] #358 In this PR, `mypy` is added but in order for CI to pass, the `# type: ignore[]` syntax is used throughout. I didn't want to tackle these here too (see #308) as it gets quite messy. One thing I have done (following #356) is change every empty `npt.NDArray` to `npt.NDArray[typing.Any]` (see #330), as this actually results in fewer errors than leaving them all blank. Ideally, we'd like to fill in as many of the `typing.Any` as possible - they're a bit useless by themselves. However, that is not the priority for now. Plus, I expect typing to change when #67 is tackled.
Merging in #359 now |
Closing in favour of #368 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
enhancement
New feature or request
infrastructure
Project infrastructure: dev tools, packaging, etc.
maintenance
Maintenance: refactoring, typos, etc.
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.
Closes #280. I anticipate this being a fair bit of work. I will use
# type: ignore[ ]
syntax throughout to minimise the initial work. I will raise a similar issue to #248 to address this.