frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Comparing Python Type Checkers: Typing Spec Conformance

https://pyrefly.org/blog/typing-conformance-comparison/
65•ocamoss•6h ago

Comments

persedes•4h ago
Article is a nice write up of https://htmlpreview.github.io/?https://github.com/python/typ...

(glad they include ty now)

Pay08•3h ago
I still can't get over the utter idiocy in Python's type hints being decorative. In what world does x: int = "thing" not give someone in the standardisation process pause?
dcreager•3h ago
Can you elaborate what you mean by decorative?

If you run a type checker like ty or pyright they're not decorative — you'll get clear diagnostics for that particular example [1], and any other type errors you might have. You can set up CI so that e.g. blocks PRs from being merged, just like any other test failure.

If you mean types not being checked at runtime, the consensus is that most users don't want to pay the cost of the checks every time the program is run. It's more cost-effective to do those checks at development/test/CI time using a type checker, as described above. But if you _do_ want that, you can opt in to that using something like beartype [2].

[1] https://play.ty.dev/905db656-e271-4a3a-b27d-18a4dd45f5da

[2] https://github.com/beartype/beartype/

badlibrarian•2h ago
It's a community that delayed progress for a decade while they waited for everyone to put parenthesis on the print statement. Give 'em enough time and they'll figure out best practices.
Spivak•1h ago
In C-ish languages the statement

    int x = "thing"
is perfectly valid. It means reserve a spot for a 32 bit int and then shove the pointer to the string "thing" at the address of x. It will do the wrong thing and also overflow memory but you could generate code for it. The type checker is what stops you. It's the same in Python, if you make type checking a build breaker then the annotations mean something. Types aren't checked at runtime but C doesn't check them either.
lefra•29m ago
In C, int may be as small as 16 bits You may get 32 bits (or more) but it's not guaranteed. I don't see how you get a memory overflow though?

I'd be surprised if a compiler with -Wall -Werror accepts to compile this.

Trying to cast back the int to a char* might work if the pointers are the same size as int on the target platform, but it's actually Undefined Behaviour IIRC.

Daishiman•1h ago
It's the complete opposite. The objective of type hints is that they're optional precisely because type hints narrow the functionality of the language. And evidenced by the fact that different type checks have different heuristics for determining what is a valid typed program and what isn't, it seems that the decision is correct.

No type system will allow for the dynamism that Python supports. It's not a question of how you annotate types, it's about how you resolve types.

hrmtst93837•51m ago
Optional on paper, sure. Once you publish shared libs or keep a nontrivial repo usable across teams, type hints stop feeling optional fast, because the minute mypy, pyright, and Pyre disagree on metaprogramming or runtime patching you get three incompatible stories about the same program and a pile of contraditions instead of signal. Python can stay dynamic, yet this setup mostly buys busywork for CI and false confidence for humans.
martinky24•3h ago
I've been using ty on some previously untyped codebases at work. It does a good job of being fast and easy to use while catching many issues without being overly draconian.

My teammates who were writing untyped Python previously don't seem to mind it. It's a good addition to the ecosystem!

tfrancisl•3h ago
And it makes it infinitely easier for them to get with the times and start typing their code!
Scene_Cast2•3h ago
Are there any good static (i.e. not runtime) type checkers for arrays and tensors? E.g. "16x64x256 fp16" in numpy, pytorch, jax, cupy, or whatever framework. Would be pretty useful for ML work.
ocamoss•2h ago
We're working on statically checking Jaxtyping annotations in Pyrefly, but it's incomplete and not ready to use yet :)
jmalicki•2h ago
Have you looked at jaxtyping? I've found it to be pretty useful - it works for PyTorch not just Jax.

https://github.com/patrick-kidger/jaxtyping

westurner•2h ago
- /?hnlog pycontract icontract https://westurner.github.io/hnlog/ :

From https://news.ycombinator.com/item?id=14246095 (2017) :

> PyContracts supports runtime type-checking and value constraints/assertions (as @contract decorators, annotations, and docstrings).

> Unfortunately, there's yet no unifying syntax between PyContracts and the newer python type annotations which MyPy checks at compile-type.

Or beartype.

Pycontracts has: https://andreacensi.github.io/contracts/ :

  @contract
  def my_function(a : 'int,>0', b : 'list[N],N>0') -> 'list[N]':
  
  @contract(image='array[HxWx3](uint8),H>10,W>10')
  def recolor(image):
For icontract, there's icontract-hyothesis.

parquery/icontract: https://github.com/Parquery/icontract :

> There exist a couple of contract libraries. However, at the time of this writing (September 2018), they all required the programmer either to learn a new syntax (PyContracts) or to write redundant condition descriptions ( e.g., contracts, covenant, deal, dpcontracts, pyadbc and pcd).

  @icontract.require(lambda x: x > 3, "x must not be small")
  def some_func(x: int, y: int = 5) -> None:
icontract with numpy array types:

  @icontract.require(lambda arr: isinstance(arr, np.ndarray))
  @icontract.require(lambda arr: arr.shape == (3, 3))
  @icontract.require(lambda arr: np.all(arr >= 0), "All elements must be non-negative")
  def process_matrix(arr: np.ndarray):
      return np.sum(arr)

  invalid_matrix = np.array([[1, -2, 3], [4, 5, 6], [7, 8, 9]])
  process_matrix(invalid_matrix)
  # Raises icontract.ViolationError
extr•1h ago
Wow, quite surprising results. I have been working on a personal project with the astral stack (uv, ruff, ty) that's using extremely strict lint/type checking settings, you could call it an experiment in setting up a python codebase to work well with AI. I was not aware that ty's gaps were significant. I just tried with zuban + pyright. Both catch a half dozen issues that ty is ignoring. Zuban has one FP and one FN, pyright is 100% correct.

Looks like I will be converting to pyright. No disrespect to the astral team, I think they have been pretty careful to note that ty is still in early days. I'm sure I will return to it at some point - uv and ruff are excellent.

pgwalsh•36m ago
Using VSCodium I was having issues with python type checkers for quite a while. I did the basedpyright thing for a while but that was painful. It's a bit too based for me, and I'm not sure i'd call it based. Right now I have uv, ruff, and ty and I'm happy with it. It's super easy to update and super fast. I didn't realize the coverage wasn't as good as some others but I still like it. I may have to try pyrefly. Never heard of it until this post, so thank you.

Jemalloc un-abandoned by Meta

https://engineering.fb.com/2026/03/02/data-infrastructure/investing-in-infrastructure-metas-renew...
69•hahahacorn•40m ago•13 comments

The “small web” is bigger than you might think

https://kevinboone.me/small_web_is_big.html
96•speckx•1h ago•27 comments

Palestinian boy, 12, describes how Israeli forces killed his family in car

https://www.bbc.com/news/articles/c70n2x7p22do
109•tartoran•15m ago•6 comments

My Journey to a reliable and enjoyable locally hosted voice assistant

https://community.home-assistant.io/t/my-journey-to-a-reliable-and-enjoyable-locally-hosted-voice...
196•Vaslo•5h ago•64 comments

Apideck CLI – An AI-agent interface with much lower context consumption than MCP

https://www.apideck.com/blog/mcp-server-eating-context-window-cli-alternative
76•gertjandewilde•3h ago•78 comments

Launch HN: Voygr (YC W26) – A better maps API for agents and AI apps

34•ymarkov•2h ago•15 comments

Why I love FreeBSD

https://it-notes.dragas.net/2026/03/16/why-i-love-freebsd/
223•enz•7h ago•83 comments

Cert Authorities Check for DNSSEC from Today

https://www.grepular.com/Cert_Authorities_Check_for_DNSSEC_From_Today
51•zdw•20h ago•51 comments

Language Model Teams as Distrbuted Systems

https://arxiv.org/abs/2603.12229
12•jryio•1h ago•1 comments

Kaizen (YC P25) Hiring Eng, GTM, Cos to Automate BPOs

https://www.kaizenautomation.com/careers
1•michaelssilver•1h ago

Polymarket gamblers threaten to kill me over Iran missile story

https://www.timesofisrael.com/gamblers-trying-to-win-a-bet-on-polymarket-are-vowing-to-kill-me-if...
927•defly•6h ago•580 comments

Corruption erodes social trust more in democracies than in autocracies

https://www.frontiersin.org/journals/political-science/articles/10.3389/fpos.2026.1779810/full
556•PaulHoule•7h ago•273 comments

US Job Market Visualizer

https://karpathy.ai/jobs/
259•andygcook•3h ago•220 comments

Launch HN: Chamber (YC W26) – An AI Teammate for GPU Infrastructure

https://www.usechamber.io/
7•jshen96•1h ago•2 comments

Lazycut: A simple terminal video trimmer using FFmpeg

https://github.com/emin-ozata/lazycut
94•masterpos•6h ago•33 comments

Starlink Mini as a failover

https://www.jackpearce.co.uk/posts/starlink-failover/
55•jkpe•10h ago•80 comments

The return-to-the-office trend backfires

https://thehill.com/opinion/technology/5775420-remote-first-productivity-growth/
32•penguin_booze•40m ago•5 comments

Home Assistant waters my plants

https://finnian.io/blog/home-assistant-waters-my-plants/
200•finniananderson•4d ago•91 comments

MoD sources warn Palantir role at heart of government is threat to UK security

https://www.thenerve.news/p/palantir-technologies-uk-mod-sources-government-data-insights-securit...
466•vrganj•6h ago•173 comments

Speed at the cost of quality: Study of use of Cursor AI in open source projects

https://arxiv.org/abs/2511.04427
39•wek•1h ago•16 comments

Even faster asin() was staring right at me

https://16bpp.net/blog/post/even-faster-asin-was-staring-right-at-me/
75•def-pri-pub•6h ago•39 comments

Kona EV Hacking

http://techno-fandom.org/~hobbit/cars/ev/
76•AnnikaL•4d ago•46 comments

Lies I was told about collaborative editing, Part 2: Why we don't use Yjs

https://www.moment.dev/blog/lies-i-was-told-pt-2
140•antics•3d ago•73 comments

Comparing Python Type Checkers: Typing Spec Conformance

https://pyrefly.org/blog/typing-conformance-comparison/
65•ocamoss•6h ago•22 comments

AirPods Max 2

https://www.apple.com/airpods-max/
84•ssijak•5h ago•150 comments

On The Need For Understanding

https://blog.information-superhighway.net/on-the-need-for-understanding
16•zdw•4d ago•4 comments

The bureaucracy blocking the chance at a cure

https://www.writingruxandrabio.com/p/the-bureaucracy-blocking-the-chance
33•item•1d ago•54 comments

Event Publisher enables event integration between Keycloak and OpenFGA

https://github.com/embesozzi/keycloak-openfga-event-publisher
19•mooreds•4h ago•4 comments

Human Organ Atlas

https://human-organ-atlas.esrf.fr/
34•giuliomagnifico•1d ago•3 comments

'Pokémon Go' players unknowingly trained delivery robots with 30B images

https://www.popsci.com/technology/pokemon-go-delivery-robots-crowdsourcing/
136•wslh•5h ago•74 comments