Merged
Conversation
2 tasks
Collaborator
tonyandrewmeyer
left a comment
There was a problem hiding this comment.
Is the switch to the future import required for the pyright change? I'm happy to make that change, but if it's not part of the required changes could you add some info about it to the PR description?
benhoyt
reviewed
Aug 25, 2024
Collaborator
benhoyt
left a comment
There was a problem hiding this comment.
Nice, thanks!
Can we also make sure that charms that use MyPy still type check okay? I did a fair bit of work when updating the types to ensure that charms could use either Pyright or MyPy. We should probably have a some kind of automated test for this.
benhoyt
approved these changes
Aug 27, 2024
IronCore864
approved these changes
Aug 28, 2024
dimaqq
added a commit
that referenced
this pull request
Aug 28, 2024
Parent: https://warthogs.atlassian.net/browse/CHARMTECH-232 Covered in the parent epic: - charmcraft analyse will validate that charm Python entrypoint calls ops.main - it is static type checker’s job to ensure correct arguments to ops.main - today, many charms do and have to do ops.main(ThisCharm) # type: ignore - thus, type hints need to be improved so that typpe: ignore can be dropped Plan in this story: - upgrade pyright (not sure if strictly necessary, #1332) - enabled pyright setting reportUnnecessaryTypeIgnoreComment - include code that calls ops.main(SomeCharm) in every which legal way in ops tests somewhere - pyright validates the positive case, that ops.main can be called with a charm class - include code that calls ops.main() without a charm class - pyright now validates that such invocation is detected as an error - thus, this invocation is annotated with # type: ignore or similar - with the setting above, pyright also enforce that the annotation is actually needed Ref: "How to write negative type tests?" microsoft/pyright#8803 Part 2, based on #1332 MyPy checks, pinned mypy: - [x] `nginx-ingress-integrator-operator` mypy 1.6.1 OK - [x] `sdcore-webui-operator` mypy 1.11.1 OK Super-tox, running on host (macos) - 58 charms pass against canonical/operator@main - 58 charms pass against dimaqq/aoperator@pyright-reportUnnecessaryTypeIgnoreComment
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.
In preparation to enabling
reportUnnecessaryTypeIgnoreComment, bumping pyright to today's latest.super-tox run: OK (tested on host, macos)