Skip to content

int.denominator, int.imag: More precise return types #8266

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

Merged
merged 1 commit into from
Jul 14, 2022

Conversation

AlexWaygood
Copy link
Member

No description provided.

@github-actions
Copy link
Contributor

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

@AlexWaygood AlexWaygood marked this pull request as ready for review July 10, 2022 14:30
@JelleZijlstra
Copy link
Member

Would this fall under #7258? I can't imagine much real-world code being affected though.

@AlexWaygood
Copy link
Member Author

Would this fall under #7258? I can't imagine much real-world code being affected though.

I'd argue "no", since the problems raised in that issue are mainly to do with class-level and module-level constants (#7258 (comment)). So the risk seems small imo... but yeah, the benefits are also probably small as well.

I don't have a particularly strong opinion on this — I was just looking at int because of all the renewed talk about typing & numbers recently, and noticed that fractions.Fraction has a much more precise annotation here:

def imag(self) -> Literal[0]: ...

@srittau
Copy link
Collaborator

srittau commented Jul 11, 2022

Please note that the moratorium is for literal constants, not for all literal values. Especially return types should be fairly uncontroversial.

@Akuli Akuli changed the title int.real, int.imag: More precise return types int.denominator, int.imag: More precise return types Jul 11, 2022
@AlexWaygood AlexWaygood merged commit 9645dae into master Jul 14, 2022
@AlexWaygood AlexWaygood deleted the AlexWaygood-patch-2 branch July 14, 2022 10:25
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