Skip to content

refactor: mark consts as final - #69

Merged
jkowalleck merged 9 commits into
mainfrom
refactor/mark-consts-as-final
Jul 24, 2026
Merged

jkowalleck merged 9 commits into
mainfrom
refactor/mark-consts-as-final

Conversation

@jkowalleck

Copy link
Copy Markdown
Collaborator
  • Refactor
    • Marked exported constants/lazy globals as Final for downstream users

Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
@read-the-docs-community

read-the-docs-community Bot commented Jul 24, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 rfc3987-syntax2 | 🛠️ Build #33744864 | 📁 Comparing 7182c92 against latest (1b9cf9b)

  🔍 Preview build  

2 files changed
± changelog.html
± autoapi/rfc3987_syntax2/syntax_helpers/index.html

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Refactors rfc3987_syntax2’s public module-level constants and lazily-loaded globals to be annotated as Final (and related typing refinements) so downstream type checkers treat them as non-rebindable.

Changes:

  • Annotated exported constants (RFC3987_SYNTAX_*) and validator mapping as Final with broader container types (Sequence, Mapping).
  • Converted T_SYNTAX_VALIDATOR to an explicit type-alias style declaration.
  • Added an Unreleased changelog entry for the refactor.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
src/rfc3987_syntax2/syntax_helpers.py Adds Final/typing annotations for exported constants and lazy globals; adjusts type alias definition.
CHANGELOG.md Documents the refactor in the Unreleased section.
Comments suppressed due to low confidence (3)

src/rfc3987_syntax2/syntax_helpers.py:584

  • # type:ignore[...] is missing the required space (# type: ignore[...]), so this may not be recognized by type checkers.
    syntax_parser: Final[Lark]  # type:ignore[misc]  # lazy loading is Final downstream

src/rfc3987_syntax2/syntax_helpers.py:591

  • # type:ignore[...] is missing the required space (# type: ignore[...]), so this assignment may still be flagged by type checkers as reassigning a Final.
        grammar = _get_grammar()  # type:ignore[misc]  # lazy loading is Final downstream

src/rfc3987_syntax2/syntax_helpers.py:595

  • # type:ignore[...] is missing the required space (# type: ignore[...]), so this assignment may still be flagged by type checkers as reassigning a Final.
        syntax_parser = _get_syntax_parser()  # type:ignore[misc]  # lazy loading is Final downstream

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/rfc3987_syntax2/syntax_helpers.py Outdated
Comment thread src/rfc3987_syntax2/syntax_helpers.py Outdated
Comment thread src/rfc3987_syntax2/syntax_helpers.py Outdated
Comment thread src/rfc3987_syntax2/syntax_helpers.py Outdated
Comment thread CHANGELOG.md Outdated
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (2)

src/rfc3987_syntax2/syntax_helpers.py:127

  • Same as RFC3987_SYNTAX_TERMS: this is a list literal, so Final[list[T_SYNTAX_PARSER_TERM]] more accurately describes the exported object than Final[Sequence[...]] (which can imply read-only semantics).
_SYNTAX_PARSER_STARTS: Final[Sequence[T_SYNTAX_PARSER_TERM]] = ["iri", "iri_reference", "absolute_iri"]

src/rfc3987_syntax2/syntax_helpers.py:529

  • The comment implies a frozen/read-only mapping, but the value is a plain dict. If you’re only marking it as non-rebindable for typing purposes, consider using Final[dict[...]] and removing the frozen mapping implication.
RFC3987_SYNTAX_TERM_VALIDATORS: Final[Mapping[str, T_SYNTAX_VALIDATOR]] = {  # frozendict / MappingProxyType

Comment thread src/rfc3987_syntax2/syntax_helpers.py Outdated
Comment thread src/rfc3987_syntax2/syntax_helpers.py
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/rfc3987_syntax2/syntax_helpers.py:529

  • Inline comment suggests this mapping is a "frozendict / MappingProxyType", but the value is currently a plain dict literal (still mutable at runtime). Either wrap it in a real read-only container, or adjust the comment so it doesn’t imply runtime immutability that isn’t provided.

@jkowalleck
jkowalleck merged commit b59f219 into main Jul 24, 2026
23 checks passed
@jkowalleck
jkowalleck deleted the refactor/mark-consts-as-final branch July 24, 2026 14:33
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.

2 participants