-
Notifications
You must be signed in to change notification settings - Fork 578
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 and improve hypothesis.extra.numpy typing #3889
Fix and improve hypothesis.extra.numpy typing #3889
Conversation
a8139c9
to
9b19532
Compare
MyPy does not complain locally of the error in the CI. |
Wow - thanks so much @JonathanPlasse, this looks fantastic!
I would be delighted to accept PRs for better type annotations across our public API. For internals, we're happy to annotate where it's simple, but correct types would often be very very complex and at some point it's not worth the overhead. Keep it simple and we're usually happy though! |
@JonathanPlasse let me know if there's anything I can help with; there's no rush but also no need to stay stuck if you'd prefer to hand over part of the todo list 🙂 |
@Zac-HD I am currently in holidays. |
8f91a65
to
51a37e3
Compare
OK, remaining items before I can merge this - we're close!
I'm really excited about the new precision about elements types, that's going to be great for users 😁 |
Ah, got it! We needed to (1) install I've checked locally that the dtypes strategies git picked up properly; since I'm short on time I'm going to merge the PR now (it's clearly an improvement on the status quo!) and we can come back and get some additional tests into CI later. Thanks again @JonathanPlasse 😍 |
You are welcome! Will come back for more. |
Hi,
![Screenshot from 2024-02-18 14-55-11](https://private-user-images.githubusercontent.com/13716151/305719919-c35d81c8-9e9d-440a-85f7-bebd1a9be840.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA2ODI2MTIsIm5iZiI6MTcyMDY4MjMxMiwicGF0aCI6Ii8xMzcxNjE1MS8zMDU3MTk5MTktYzM1ZDgxYzgtOWU5ZC00NDBhLTg1ZjctYmViZDFhOWJlODQwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzExVDA3MTgzMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZlMzc1NjNlYzdhN2M2NTJjOTRjZmU3ODEzZjY1OWYzOTBiNDVhNTBlYjFhZTlkZTgwYTVhZDM0NGJlMzY3MWYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.-JLPXV3q2jlKwYgIyS35ENjnywJ95fSY5Cn_SiheLBg)
![Screenshot from 2024-02-18 14-54-13](https://private-user-images.githubusercontent.com/13716151/305719882-598d6708-a669-43d5-a846-ef3de183b5e5.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA2ODI2MTIsIm5iZiI6MTcyMDY4MjMxMiwicGF0aCI6Ii8xMzcxNjE1MS8zMDU3MTk4ODItNTk4ZDY3MDgtYTY2OS00M2Q1LWE4NDYtZWYzZGUxODNiNWU1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzExVDA3MTgzMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQ5ZGU4NDY3NDBiYjUwNjZkNDc1YmY2YzZhNmQ2YzBlZGU5ZTVhZWFmYzJjMTZkZDZlZGUyNjE5NzgyYjJlYzYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Gv_kSQMlT3gedLi395KBsoP3UD4zmytyhJXHWaFhE6c)
Love hypothesis.
I have been using it for years now.
Some times ago, I stumbled on a problem when using Pyright in strict mode.
When importing
hypothesis.extra.numpy.arrays
, Pyright reported the errorreportUnknownVariableType
.I opened this issue microsoft/pyright#7279 and came here to fix it.
Before:
After:
There are more to address like
array_dtypes
,from_dtype
,scalar_dtypes
that I could address in future PRs.Also, I am interested in starting to contribute to Hypothesis.
To get started, I was thinking of adding type hints to the entirety of
hypothesis.extra.numpy
and the internal it calls.Would this be welcomed?