-
Notifications
You must be signed in to change notification settings - Fork 97
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
Type hint bug for frozenbitarray? #175
Comments
Thank for your using bitarray! I'm not too familiar with mypy myself, but it would indeed be nice if mypy or other type checker could reflect this. I just wrote a file
Then:
So mypy thinks I'm not familiar enough with type hinting to solve this, but I'm visiting PyCon 2022 over the next few days, and I'm sure someone can tell me the answer. |
That was a quick response! 👍 I see that this also extends to If you want to try something, I suspect that making the following changes to the right methods in
But do not take my word for it, as I guess there might be some unwanted consequences like usual when I am trying to generalise types hints like this. As you say, the people at PyCon probably have better input on this. |
What you are suggesting makes sense, as |
It seems that type checkers give
frozenbitarray() & bitarray() -> bitarray
etc., whereas the implementation gives frozenbitarray. The implementation is a nice feature when one knows about it, and it would be nice if the type hints would reflect this.It looks to me, after reading some mypy docs, like it perhaps can be solved with some TypeVar bound to bitarray for self and the return type in
__init__.pyi
. However, I do not know enough about bitarray and type hinting to know if this would be the way to go.The text was updated successfully, but these errors were encountered: