Skip to content

When a has type Any, after assert a is None, the rest of the block is considered dead code #2970

@benkuhn

Description

@benkuhn

Steps to reproduce:

  1. Check out this repo
  2. Install the packages from requirements.txt
  3. Run mypy repro.py from the repo root.

Expected output:

repro.py:4: error: Revealed type is 'Any'
repro.py:6: error: Revealed type is 'builtins.None'

Actual output:

repro.py:4: error: Revealed type is 'Any'

The issue goes away if you disable strict Optional checking.

This is preventing a significant amount of our codebase from being checked right now, so I would appreciate any suggestions for a workaround!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions