[Python-ideas] Semantics for type checking (was: What should a good type checker do?)

Steven D'Aprano steve at pearwood.info
Sat Sep 3 21:20:58 EDT 2016


On Sun, Sep 04, 2016 at 12:26:58AM +0300, Koos Zevenhoven wrote:
> On Friday, while replying to a post on python-dev about PEP 526
> (variable annotations), I ended up mentioning things that I think a
> good type checker should do, which seem to differ from the general
> understanding. The discussion should continue here, though, because
> the aim of PEP 526 is not to define type-checking semantics.

Why should it continue here? The semantics of a type-checker is not part 
of Python the language. This is "python-ideas", not "third-party- 
application-ideas". If this thread belongs anywhere, it is probably the 
code quality mailing list.

It is very likely that different linters and type-checkers will take 
different approaches. Some may infer more, some may infer less, and 
that's a good thing.

Before arguing what a type-checker should or shouldn't do, perhaps we 
ought to look at what MyPy, PyLint, PyChecker, PyFlakes and Jedi already 
do. (Apologies if I have missed anyone's favourite linter/checker.) We 
should not try to specify the behaviour of the type-checker. Let the 
type-checkers compete in the wider Python eco-system and converge to 
best practice as found by experience, not because we declare by fiat 
that Thou Shalt Do It This Way.



-- 
Steve


More information about the Python-ideas mailing list