Skip to content

Mismatched type annotation for cover flag in cre.py #669

@shreyakash24

Description

@shreyakash24

Description

The cover parameter in the test command (defined in cre.py) is currently annotated as:

def test(cover: coverage.Coverage, test_names: List[str]) -> None:

However, the cover argument is a boolean flag passed by Click (--cover/--no-cover) and should be annotated as bool.


Steps to Reproduce

  1. Open cre.py.
  2. Locate the test function decorated with @app.cli.command().
  3. Inspect the type annotation for cover.

Observed Behavior

  • cover is annotated as coverage.Coverage.
  • Static type checkers like mypy may report a mismatch or misleading type information.

Expected Behavior

  • cover should be annotated as bool:
def test(cover: bool, test_names: List[str]) -> None:
  • This matches Click’s boolean flag behavior and passes static type checks.

Additional Context

  • The Coverage object is correctly created inside the function as COV = coverage.coverage(...).
  • Changing the annotation does not affect runtime behavior.
  • Improves code clarity, maintainability, and static analysis correctness.

Suggested Fix

  1. Update the type annotation in cre.py:
def test(cover: bool, test_names: List[str]) -> None:
  1. Run mypy to verify no type errors.
  2. Run all other tests to ensure nothing else is broken.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions