-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Initial pika stubs #9200
Initial pika stubs #9200
Conversation
This is the unmodified output of create_baseline_stubs.py
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I skimmed -- mostly looks good! Just a few things I spotted.
Do we need all the LOGGER
annotations -- are these meant to be exposed to end users? If not, maybe it would be better to allowlist them?
ON_LINUX: Final[bool] | ||
ON_OSX: Final[bool] | ||
ON_WINDOWS: Final[bool] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you could plausibly want to monkey-patch these for testing purposes, which would make the Final[]
annotation a little annoying?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the other hand, outside of testing, overriding these would potentially be fatal. Even for testing, changing these is potentially fragile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a strong opinion — it was just a thought :) feel free to ignore
Probably not, but the same is usually true for lots of implementation detail. I'm not sure why we should special case loggers. |
Well, I don't see it as special-casing loggers exactly, since, in general, I think we should limit the implementation details we expose in stubs to the bare minimum :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good (other than my minor nit about the LOGGER
variables)
This was discussed in the past. Personally, I agree with you. If I had my way, we'd just include public API (with well-documented exceptions). This would help with the maintenance nightmare that SQLAlchemy or just now fpdf2 is. But IIRC it was decided way back, that basically all "accessible" items should be typed. I can't find the exact discussion now, though. |
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
For what it's worth I don't recall such a discussion. I think we should include everything that's "clearly public" (e.g. if it's mentioned in documentation or |
Maybe we should discuss it again then, since most of us seem to agree. But currently we do the opposite and stubtest kind of pushes us towards including everything that's not explicitly marked as private. |
https://github.com/pika/pika
These stubs are basically create_baseline_stubs + fixes. I have more annotations lined up in later PRs. This PR is best reviewed commit by commit.