leinardi / mypy-pycharm

A plugin providing both real-time and on-demand scanning of Python files with Mypy from within PyCharm/IDEA.
Apache License 2.0
188 stars 30 forks source link

Big delay with scanning the current file #74

Open zljubisic opened 3 years ago

zljubisic commented 3 years ago

PyCharm 2021.1 Proffesional MyPy plugin 0.11.2 MyPy 0.812 OS: Windows 10 Prof. 64

Simple code like this one:

from typing import Protocol, List

class Template(Protocol):
    name: str        # This is a protocol member
    value: int = 0   # This one too (with default)
    temp: List[int]

    def method(self) -> None:
        self.temp: List[int] = []  # Error in type checker

class Concrete:
    def __init__(self, name: str, value: int) -> None:
        self.name = name
        self.value = value
        # self.temp = [1] #intentionally commented out in order to not satisfy Template protocol

    def method(self) -> None:
        return

var: Template = Concrete('value', 42)  # OK

In terminal always produces correct result:

(x360_base) C:\Users\User\projekt\personal\obrisi>mypy abstract\protocol_member.py
abstract\protocol_member.py:23: error: Incompatible types in assignment (expression has type "Concrete", variable has type "Template")
abstract\protocol_member.py:23: note: 'Concrete' is missing following 'Template' protocol member:
abstract\protocol_member.py:23: note:     temp
Found 1 error in 1 file (checked 1 source file)

But in pycharm, using plugin, if I press "Check current file" I get "Mypy found no problems". If I wait for few minutes I get:

Mypy found 1 error, 2 notes  in 1 file
protocol_member.py : 1 error, 2 notes 
Incompatible types in assignment (expression has type "Concrete", variable has type "Template") (23:17)
'Concrete' is missing following 'Template' protocol member (23:17)
temp (23:17)

As I can see, If I uncomment commented line in order to make the file correct, than press "Check current file", I will get "Mypy fount no problems. Now if I comment out the line in order to make the file incorrect, and press "Check current file" again, I will still get the same message: "Check current file". But if I now execute in terminal the line mentioned above, and aftewards press "Check current file", I will get error report immediately. Looks like plugin has a communication problem with mypy.exe.

Why the delay? It is very confusing. Can I somehow get immediate correct response with no delay?