Skip to content

Inconsistent behavior of # type: ignore for whole file between python versions #7785

Closed
@isac322

Description

@isac322
  • Are you reporting a bug, or opening a feature request?

A bug

  • Please insert below the code you are checking with mypy

test.py:

# type: ignore

def test1():
    return 1

print(test1())
  • What is the actual output?

with mypy test.py --strict:

Success: no issues found in 1 source file

with mypy test.py --strict -2:

test.py:1: error: unused 'type: ignore' comment
test.py:3: error: Function is missing a return type annotation
test.py:6: error: Call to untyped function "test1" in typed context
Found 3 errors in 1 file (checked 1 source file)
  • What is the output you expect?

both mypy test.py --strict and mypy test.py --strict -2:

Success: no issues found in 1 source file
  • What are the versions of mypy and Python you are using?

    • mypy: 0.740
    • python: 3.7.4
  • Do you see the same issue after installing mypy from Git master?

Yes (on 09c1fc7)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions