Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicit 'comparison' with mypy #50

Open
disconnect3d opened this issue Oct 17, 2018 · 10 comments
Open

Explicit 'comparison' with mypy #50

disconnect3d opened this issue Oct 17, 2018 · 10 comments

Comments

@disconnect3d
Copy link

Hey,

It might be good to put a typeguard vs mypy in readme. I know those are different projects (runtime vs static) but that was my first question to a friend who linked it, so I guess other ppl might ask it too :P.

@agronholm
Copy link
Owner

What do I say besides the fact that typeguard works at run time and mypy is a static analyzer? I'm not sure I'm qualified to do an in-depth comparison.

@disconnect3d
Copy link
Author

disconnect3d commented Oct 17, 2018 via email

@mixmastamyk
Copy link

One other reason I tried and stuck with typeguard instead of mypy or pydantic is that it is 1/100th the size! From a cursory view it looks like this is a pure Python lib and the others need lots of stuff built with a compiler. I haven't looked deep to see if that is true however.

Great library by the way—I looked high and low for a function like check_type() and this is the first place I found it. ;-)

@agronholm
Copy link
Owner

Thanks. Typeguard has a long way to go though, and has a tiny fraction of the mindshare that the static checkers have.

@mixmastamyk
Copy link

Maybe a blurb in the docs could help. It can always grow in the future if needed.

@oleks
Copy link

oleks commented Nov 15, 2021

Can it not make sense to use both typeguard and mypy?

@agronholm
Copy link
Owner

Yes, that is how the majority of the users (as I understand) use typeguard. Typeguard is an additional layer of safeguards.

@oleks
Copy link

oleks commented Nov 15, 2021

Yes, that is how the majority of the users (as I understand) use typeguard. Typeguard is an additional layer of safeguards.

Cool, but then why do I get an error like this when trying to mypy code that uses typeguard:

error: Cannot find implementation or library stub for module named "typeguard"
note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

@agronholm
Copy link
Owner

Currently typeguard itself does not pass mypy checks (due to a number of workarounds) so it does not expose its type information to mypy, hence the error. This is something I want to solve, possibly in the next major release, if it's doable. In the meantime, I suggest you have mypy ignore these errors (a lot of libraries don't have type information available).

@agronholm
Copy link
Owner

As of v3.0.0, typeguard now passes mypy checks in strict mode. It also now contains py.typed, marking it as a typed library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants