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

Initial pika stubs #9200

Merged
merged 10 commits into from
Nov 21, 2022
Merged

Initial pika stubs #9200

merged 10 commits into from
Nov 21, 2022

Conversation

srittau
Copy link
Collaborator

@srittau srittau commented Nov 15, 2022

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.

@github-actions

This comment has been minimized.

Copy link
Member

@AlexWaygood AlexWaygood left a 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?

Comment on lines +14 to +16
ON_LINUX: Final[bool]
ON_OSX: Final[bool]
ON_WINDOWS: Final[bool]
Copy link
Member

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?

Copy link
Collaborator Author

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.

Copy link
Member

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

stubs/pika/pika/amqp_object.pyi Outdated Show resolved Hide resolved
stubs/pika/pika/spec.pyi Outdated Show resolved Hide resolved
stubs/pika/pika/data.pyi Outdated Show resolved Hide resolved
stubs/pika/pika/validators.pyi Outdated Show resolved Hide resolved
@srittau
Copy link
Collaborator Author

srittau commented Nov 21, 2022

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?

Probably not, but the same is usually true for lots of implementation detail. I'm not sure why we should special case loggers.

@AlexWaygood
Copy link
Member

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 :)

Copy link
Member

@AlexWaygood AlexWaygood left a 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)

@srittau
Copy link
Collaborator Author

srittau commented Nov 21, 2022

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.

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau srittau merged commit ebb5bdd into python:main Nov 21, 2022
@srittau srittau deleted the pika branch November 21, 2022 18:31
@JelleZijlstra
Copy link
Member

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.

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 __all__), and skip private-looking stuff unless people explicitly ask for it.

@srittau
Copy link
Collaborator Author

srittau commented Nov 22, 2022

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.

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.

3 participants