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

Fix mypy complaints about TraitError #1658

Merged
merged 3 commits into from
Jun 30, 2022
Merged

Conversation

mdickinson
Copy link
Member

Projects using traits-stubs reported that mypy was complaining about not having information about TraitError. This PR should fix that.

I've also added some instructions on local development to the README, since I have to figure this out every time.

@mdickinson
Copy link
Member Author

The traits_stubs_tests don't fail even if I remove the fix (and keep the completeness.py file). Making this a draft while I investigate.

@mdickinson mdickinson marked this pull request as draft June 29, 2022 10:43
@mdickinson
Copy link
Member Author

Making this a draft while I investigate.

I'm seeing the following behaviour locally: two identical files, one of which type-checks without error and the other of which fails:

(traits-stubs) mdickinson@mirzakhani traits % cd traits-stubs                                                                            
(traits-stubs) mdickinson@mirzakhani traits-stubs % python -m mypy /var/folders/07/jbbjv8b53bs5y9xyjdyn1zgw0000gn/T/tmph57yyah5/completeness.py
Success: no issues found in 1 source file
(traits-stubs) mdickinson@mirzakhani traits-stubs % python -m mypy traits_stubs_tests/examples/completeness.py 
traits_stubs_tests/examples/completeness.py:5: error: Module "traits.api" has no attribute "TraitError"
Found 1 error in 1 file (checked 1 source file)
(traits-stubs) mdickinson@mirzakhani traits-stubs % diff -u /var/folders/07/jbbjv8b53bs5y9xyjdyn1zgw0000gn/T/tmph57yyah5/completeness.py traits_stubs_tests/examples/completeness.py 

This appears to have to do with a stale .mypy_cache, which for some reason isn't being automatically invalidated. If I delete the cache, then both cases fail as expected.

So I think this PR is okay, since the stale mypy cache problem shouldn't occur in CI.

@mdickinson mdickinson marked this pull request as ready for review June 29, 2022 10:53
Copy link
Contributor

@rahulporuri rahulporuri left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you!

@mdickinson mdickinson merged commit 4f17157 into main Jun 30, 2022
@mdickinson mdickinson deleted the stubs/fix-missing-exceptions branch June 30, 2022 07:09
mdickinson added a commit that referenced this pull request Aug 9, 2022
Projects using traits-stubs reported that mypy was complaining about not having information about TraitError. This PR should fix that.

I've also added some instructions on local development to the README, since I have to figure this out every time.

(cherry picked from commit 4f17157)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants