Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-104050: Improve some typing arounddefaults and sentinel values#104626

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
AlexWaygood merged 6 commits intopython:mainfromAlexWaygood:sentinels-clinic
May 18, 2023

Conversation

AlexWaygood
Copy link
Member

@AlexWaygoodAlexWaygood commentedMay 18, 2023
edited
Loading

  • Convertunspecified andunknown to be members of aSentinels enum, rather than instances of bespoke classes.
    • An enum feels more idiomatic here, and works better with type checkers.
    • Convert some== and!= checks for these values to identity checks, which are more idiomatic with sentinels.
    • Don't do the same forNull, as this needs to be a distinct type due to its usage inclinic.py.
  • Useobject as the annotation fordefault acrossclinic.py.default can be literally any object, soobject is the correct annotation here.

@AlexWaygood
Copy link
MemberAuthor

Not sure if converting theunspecified andunknown sentinels to become enum members is entirely worth it; now thatdefault is typed asobject anywhere, the benefits aren't so obvious. I do think it still makes the code alittle cleaner, but you tell me whether you think it's worth the churn@erlend-aasland :)

@erlend-aasland
Copy link
Contributor

Not sure if converting theunspecified andunknown sentinels to become enum members is entirely worth it; now thatdefault is typed asobject anywhere, the benefits aren't so obvious. I do think it still makes the code alittle cleaner, but you tell me whether you think it's worth the churn@erlend-aasland :)

IMO, the more readable we can get clinic.py, the better. We should thread a little careful here, sincetest_clinic has pretty low coverage. Some of the paths modified are not tested. However, the CI doesmake clinic (for the check-generated-files job), and that would blow up if semantics changed for the code in question, so we're fine for now.

AlexWaygood reacted with heart emoji

@AlexWaygood
Copy link
MemberAuthor

IMO, the more readable we can get clinic.py, the better. We should thread a little careful here, sincetest_clinic has pretty low coverage. Some of the paths modified are not tested. However, the CI doesmake clinic (for the check-generated-files job), and that would blow up if semantics changed for the code in question, so we're fine for now.

Fab. Thanks for the review!

@AlexWaygoodAlexWaygood merged commit1c55e8d intopython:mainMay 18, 2023
@AlexWaygoodAlexWaygood deleted the sentinels-clinic branchMay 18, 2023 22:42
carljm added a commit to carljm/cpython that referenced this pull requestMay 18, 2023
* main:pythongh-74690: Don't set special protocol attributes on non-protocol subclasses of protocols (python#104622)pythongh-104623: Update Windows installer to use SQLite 3.42.0 (python#104625)pythongh-104050: Add more type annotations to Argument Clinic (python#104628)pythongh-104629: Don't skip test_clinic if _testclinic is missing (python#104630)pythongh-104549: Set __module__ on TypeAliasType (python#104550)pythongh-104050: Improve some typing around `default`s and sentinel values (python#104626)pythongh-104146: Remove unused vars from Argument Clinic (python#104627)pythongh-104615: don't make unsafe swaps in apply_static_swaps (python#104620)pythonGH-104484: Add case_sensitive argument to `pathlib.PurePath.match()` (pythonGH-104565)pythonGH-96803: Document and test new unstable internal frame API functions (pythonGH-104211)pythonGH-104580: Don't cache eval breaker in interpreter (pythonGH-104581)
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@erlend-aaslanderlend-aaslanderlend-aasland approved these changes

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@AlexWaygood@erlend-aasland@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp