Skip to content

Converted sentinel types to use new sentinel class - #2131

Merged
sydduckworth merged 4 commits into
asdf-format:mainfrom
sydduckworth:use-sentinel-types
Sep 3, 2026
Merged

Converted sentinel types to use new sentinel class#2131
sydduckworth merged 4 commits into
asdf-format:mainfrom
sydduckworth:use-sentinel-types

Conversation

@sydduckworth

@sydduckworth sydduckworth commented Sep 3, 2026

Copy link
Copy Markdown
Member

Description

Closes #2122

  • Bumped typing-extensions to 4.16
  • Replaced NOT_SET and USE_INTERNAL implementation with sentinel
  • Removed NotSetType and UseInternal type aliases since sentinel lets the value and type use the same name

AI Disclosure

No AI tools used.

Tasks

  • run prek on your machine
  • run pytest on your machine
  • Does this PR add new features and / or change user-facing code / API? (if not, label with no-changelog-entry-needed)
    • write news fragment(s) in changes/: echo "changed something" > changes/<PR#>.<changetype>.rst (see below for change types)
    • update relevant docstrings and / or docs/ page
    • for any new features, add unit tests
news fragment change types...
  • changes/<PR#>.feature.rst: new feature
  • changes/<PR#>.bugfix.rst: bug fix
  • changes/<PR#>.doc.rst: documentation change
  • changes/<PR#>.removal.rst: deprecation or removal of public API
  • changes/<PR#>.general.rst: infrastructure or miscellaneous change

@braingram braingram left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the updates. The use of sentinel helps to clean up the code.

Would you open an issue to track that we can use the builtin sentinel once our minimum python version is 3.15?

@sydduckworth

Copy link
Copy Markdown
Member Author

Thanks for making the updates. The use of sentinel helps to clean up the code.

Would you open an issue to track that we can use the builtin sentinel once our minimum python version is 3.15?

Ruff has a linter rule (UP035) that triggers for typing-extensions imports that aren't necessary based on the project's minimum Python version.

We use several other types from typing-extensions in other parts of the codebase so idk if I'd want to manually track them for different versions.

@sydduckworth
sydduckworth merged commit 9006ade into asdf-format:main Sep 3, 2026
49 of 50 checks passed
@braingram

Copy link
Copy Markdown
Contributor

Thanks for pointing out the rule. The description says:

This rule thus avoids flagging imports from typing_extensions in such cases.

Testing by setting the ruff version to 3.15 it doesn't update sentinel (or report a rule violation). Perhaps the rule doesn't include sentinel yet. An issue seems more straightforward than relying on some ruff rule to be updated. #2132

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Convert sentinel types to use new sentinel class

2 participants