Skip to content

option no-implicit-optional ignored as inline configuration and per-module flags #8029

Description

@fnep

I found a potential bug (not sure) with mypy 0.740 and Python 3.6.5 & Python 3.7.1.

The following code:

# mypy: no-implicit-optional

def add(self, a: int, b: int = None) -> int:
    return a + b

… gives me

run.py:4: error: Unsupported operand types for + ("int" and "None")
run.py:4: note: Right operand is of type "Optional[int]"

… but I would expect to get the more clear

run.py:3: error: Incompatible default for argument "b" (default has type "None", argument has type "int")

… because the inline config "no-implicit-optional" is set. It is the same if I have a per file/moule section in my mypy.ini, but it works i if define it globally (in [mypy] section) or via command line switch.

Metadata

Metadata

Assignees

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions