is mypy failing here
Kirill Ratkin
niktarlirik at zohomail.com
Thu Nov 24 08:50:04 EST 2022
Hi Robin,
mypy --strict gives you detail info.
On Thu, Nov 24, 2022 at 10:05 +0000, Robin Becker wrote:
> I haven't used dataclasses or typing very much, but while playing about I found this didn't give me an expected error
>
> (.py312) robin at minikat:~/devel/reportlab
> $ cat tmp/examples/tdc.py && python tmp/examples/tdc.py && mypy tmp/examples/tdc.py
> ##################################
> from dataclasses import dataclass
>
> @dataclass
> class DC:
> a: str
> b: str
>
> def main():
> dc = DC(DC, "B")
> print(dc)
>
> if __name__ == "__main__":
> main()
> ##################################
> DC(a=<class '__main__.DC'>, b='B')
> Success: no issues found in 1 source file
> (.py312) robin at minikat:~/devel/reportlab
>
> DC.a is supposed to be a str and I expected mypy to indicate a type error
>
> should typing work for this case?
> --
> Robin Becker
> --
> https://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list