Skip to content

Consistent use of Final annotation for module-level constants #760

@oboehmer

Description

@oboehmer

Context

During review of #657, it was noted that DEFAULT_TEST_TYPE in common/types.py lacks a Final annotation, while VALID_TEST_TYPES and BASE_CLASS_MAPPING in test_type_resolver.py do use Final.

Looking at the broader codebase, none of the constants in core/constants.py or other modules use Final — only test_type_resolver.py does. Adding Final to just DEFAULT_TEST_TYPE would widen rather than narrow the inconsistency.

Discussion

Should we:

  1. Add Final to all module-level constants across the codebase (systematic, but potentially noisy)
  2. Remove the existing Final annotations from test_type_resolver.py to match the rest of the codebase
  3. Leave as-is — the value of Final for simple constants may not justify the annotation overhead

Factors to consider:

  • mypy already catches most reassignment issues through other type checks
  • Final adds value mainly for constants that could be confused with mutable variables
  • Consistency within the codebase matters more than following a theoretical best practice

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussionIssues requiring team discussion and input

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions