Visitar URL original
Simplify _exact_ratio() using duck typing by skirpichev · Pull Request #24988 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20221223162742/https://github.com/python/cpython/pull/24988
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

Simplify _exact_ratio() using duck typing #24988

Closed
wants to merge 1 commit into from

Conversation

skirpichev
Copy link
Contributor

@skirpichev skirpichev commented Mar 23, 2021

The optional as_integer_ratio() does exist not for all numeric classes of the stdlib. So, no need for type checks.

If this code does assume using types, that conform to the numbers ABC, but doesn't implement as_integer_ratio() - we could add a fallback to try (x.numerator, x.denominator) for the AttributeError.

@erlend-aasland
Copy link
Contributor

erlend-aasland commented Mar 23, 2021

I assume you mean duck typing with a u?

@skirpichev skirpichev changed the title Simplify _exact_ratio() using dick typing Simplify _exact_ratio() using duck typing Mar 23, 2021
The optional as_integer_ratio() does exist not for all
numeric classes of stdlib.
@skirpichev
Copy link
Contributor Author

skirpichev commented Mar 23, 2021 •

Sure, thanks for typo correction (letters are close on keyboard).

@skirpichev skirpichev marked this pull request as ready for review Mar 23, 2021
@github-actions
Copy link

github-actions bot commented Apr 23, 2021

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Apr 23, 2021
@skirpichev skirpichev closed this Mar 20, 2022
@skirpichev skirpichev deleted the simplify__exact_ratio branch Mar 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review stale Stale PR or inactive for long period of time.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants