News for hackers. Stuff that matters.
Re:Comparing Python Type Checkers: Typing Spec Conformance by bko on Tuesday March 17, 2026 @05:50AM (#47410515)
I dont know, I've seen some truly simple things check out as ok in mypy

Example

def foo(bar: bool) -> bool:

  if bar:
 
    m = True
 
  return m
No error that m is defined conditionally? What's going on?
Re:Comparing Python Type Checkers: Typing Spec Conformance by maleldil on Tuesday March 17, 2026 @11:40AM (#47414218)
ty and zuban also don't give an error. pyright and pyrefly do.
Re:Comparing Python Type Checkers: Typing Spec Conformance by _carljm on Thursday March 19, 2026 @10:13PM (#47449582)
We provide this diagnostic in ty (https://docs.astral.sh/ty/reference/rules/#possibly-unresolv...), but it's disabled by default because it can have false positives in many scenarios where the code works at runtime (this is true also in the type checkers that enable it by default). A typical example is code like

  def _(flag: bool):
    if flag:
      x = True
    ...
    if flag:
      read(x)
But it's easy to turn the rule on if you want it:

  [tool.ty.rules]
  possibly-unresolved-reference = "error"