faust icon indicating copy to clipboard operation
faust copied to clipboard

Records are not checked by mypy

Open antoinewdg-netapp opened this issue 2 years ago • 1 comments

It looks like mypy is treating every value of type faust.Record as Any: absolutely no type checking is done on them. This is related to #233, but larger than only constructor arguments (who IIRC cannot be done properly without a mypy plugin).

Checklist

  • [x] I have included information about relevant versions
  • [x] I have verified that the issue persists when using the master branch of Faust.

Steps to reproduce

  • main.py
from faust import Record


class Example(Record):
    x: int

Example(x=3).y
my_var: int = Example(x=3)
  • mypy main.py

Expected behavior

mypy should raise some errors

error: "Example" has no attribute "y"
error: Incompatible types in assignment (expression has type "Example", variable has type "int")

Actual behavior

mypy gives no error

Versions

OS: Linux Fedora 35

▶ python --version
Python 3.9.7

▶ pip show faust-streaming
Name: faust-streaming
Version: 0.8.4

▶ mypy --version
mypy 0.950 (compiled: yes)

antoinewdg-netapp avatar May 06 '22 09:05 antoinewdg-netapp

I think the cause is # type: ignore'ing the Record class, see here. This basically turns off the type checker for any usages of the Record class, its subclasses, and all their instances.

The whole ModelT is # type: ignore'd too, see here.

pawelswiecki avatar Aug 16 '22 13:08 pawelswiecki