Skip to content

Enforce modern best practices concerning annotations, typing and symbol import/export#102

Merged
Kalmat merged 1 commit into
Kalmat:masterfrom
Avasam:Ruff-typing-annotations-imports
Jun 18, 2026
Merged

Enforce modern best practices concerning annotations, typing and symbol import/export#102
Kalmat merged 1 commit into
Kalmat:masterfrom
Avasam:Ruff-typing-annotations-imports

Conversation

@Avasam

@Avasam Avasam commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Overlaps with #101, probably merge that one first to reduce changes.

Mostly taken from my own shared config file: https://github.com/Beslogic/Beslogic-Ruff-Config/blob/main/ruff.toml
But scoped to only rule groups that concern modernization and best practices for annotations, typing and symbol import/export.
Most of this was autofixed.

The most immediate effects here are:

  • Reduced imports (which will keep reducing in time and as older Python versions are dropped)
  • Reduced static typing workarounds
  • Avoid evaluating typing symbols when unnecessary
  • Return type annotations on public functions (mypy will infer Any if return type annotation is missing, where every other type checker will infer from the function body)
  • Explicit re-exports so that type-checkers don't have to guess if the symbols are meant to be public or internal
  • More correctness checks
  • General alignments with the rest of the Python Typing ecosystem

@Avasam Avasam requested a review from Kalmat June 16, 2026 23:29
@Avasam Avasam changed the title Enforce best practices concerning annotations, typing and symbol import/export Enforce modern best practices concerning annotations, typing and symbol import/export Jun 16, 2026
@Avasam Avasam force-pushed the Ruff-typing-annotations-imports branch from 4eb3179 to 63d933e Compare June 16, 2026 23:39
Comment thread ruff.toml
# TODO: Consider later
"UP031", # printf-string-formatting
"RUF059", # unused-unpacked-variable
"E722", # bare-except

@Avasam Avasam Jun 16, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

E722 done in #103
It's a base Ruff rule, so felt out of scope for this PR.

@Avasam Avasam force-pushed the Ruff-typing-annotations-imports branch 6 times, most recently from 1aab2ff to ce5221b Compare June 18, 2026 14:54
@Avasam Avasam force-pushed the Ruff-typing-annotations-imports branch from ce5221b to 3cf4bf8 Compare June 18, 2026 14:58
@Kalmat

Kalmat commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Sorry. Should I merge this PR or just wait?

@Avasam

Avasam commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator Author

#101 has been merged. You can merge this now.

I tried to keep my PRs as isolated as possible for review and history. Of course I expected some overlap and conflicts.

@Kalmat Kalmat merged commit 55ebdc8 into Kalmat:master Jun 18, 2026
77 of 78 checks passed
@Avasam Avasam deleted the Ruff-typing-annotations-imports branch June 18, 2026 16: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