I built a typed superset of Python that compiles to standard .py — would you use it?
Posted by unadlib@reddit | Python | View on Reddit | 25 comments
TypePython
Repo: type-python/type-python
I've been working on TypePython — a statically-typed authoring language that compiles .tpy files to standard Python .py + .pyi. No custom runtime. No vendor lock-in. The output works with mypy, pyright, ty, and any standard Python tooling.
The core idea: type checkers verify your annotations; TypePython gives you a better syntax to write them in.
you write .tpy → TypePython compiles → .py + .pyi → ty / pyright / mypy checks
Python-ModTeam@reddit
Hello there,
We've removed your post since it aligns with a topic already covered by one of our daily or monthly threads. If you are unaware about the daily threads we run here is a refresher:
Monday: Project ideas
Tuesday: Advanced questions
Wednesday: Beginner questions
Thursday: Careers
Friday: Free chat Friday!
Saturday: Resource Request and Sharing
Sunday: What are you working on?
Monthly: Showcase your new projects, tools, frameworks and more
Please await one of these threads to contribute your discussion to!
Best regards,
r/Python mod team
nick2859@reddit
I don't see how this language offers any advantage over what we already have. What's the point of the unsafe block when a linter like ruff can already highlight all the usages of eval? why add
unknownwhen we can already useobject? typealias is already in the language as the type keyword. I don't see the utility of this thing.unadlib@reddit (OP)
I didn't expect so much pushback.
Those are fair points, but I think those are the least interesting features to judge it on.
unsafeisn't trying to replace Ruff. Ruff gives you a blocklist of known bad patterns likeeval;unsafegives you an explicit audit boundary for code that's intentionally outside the type system.unknownis stricter thanobject. Withunknown, you have to narrow before doing anything meaningful with the value. That's the same idea as TypeScript'sunknown.typealiasis mostly useful if you want to target 3.10/3.11 but still write in a more modern style. If you're only targeting 3.12+, then yes, that one matters less.The more interesting parts are:
Protocol.So the pitch isn't 'every keyword here is individually novel.' The pitch is: author with stronger guarantees and better ergonomics, ship plain Python with no runtime dependency.
olivermtr@reddit
I don't know Rust very well doesn't it also use `unsafe` to allow untyped constructs? No idea why you are getting so much hate.
olivermtr@reddit
I mean typescript showed if there is enough demand and support it can gain adoption, but it'll be steep hill to climb.
Feeling_Ad_2729@reddit
The compilation step is a high bar to clear. Python's native type syntax has improved a lot in 3.10-3.12 — X|None unions, match patterns, ParamSpec, TypeVarTuple — and tools like pyright are now fast enough that the feedback loop feels native.
Genuine question: what annotation patterns did you need that the current syntax couldn't express cleanly? That's probably the strongest case for a separate compilation layer, but I'm not seeing it spelled out in the post.
jpgoldberg@reddit
I am glad that this is being developed.
But I’m not sure that I would use it unless there were some (promise of a) clear advantage over strict static type checking. Had this been created before static type checking reached the level of maturity is now has, I would very much have considered that.
But I should take a look at what you mean by “better syntax”.
aloobhujiyaay@reddit
what’s the actual win over just using type hints + pyright? is it mostly ergonomics or does it unlock stuff you can’t express today?
unadlib@reddit (OP)
Part of it is just better ergonomics, but the real draw is using stricter constructs that Python lacks today. It lowers to plain Python, so you get all the dev-time guarantees without sacrificing runtime compatibility.
SwampFalc@reddit
At least make the reference to your repo a clickable link?
unadlib@reddit (OP)
Per the rules, I'm dropping the link in the comments so the post doesn't get removed.
https://github.com/type-python/type-python
mr_frpdo@reddit
I'm curious what the better syntax is. Have some examples
fenghuangshan@reddit
what's the meaning of this?
CreativeJuice5708@reddit
Remove the feature that makes python python???
Cystems@reddit
I would just use Cython
MonsieurCellophane@reddit
No
__salaam_alaykum__@reddit
🤔
synept@reddit
Python already has type annotations and they work well.
The_Ritvik@reddit
Hell no.
JavaScript is already confusing enough with TypeScript — what we need a TypePython for, bros ??
ZeeBeeblebrox@reddit
Seems to be similar to SPy but more limited
simion_baws@reddit
hillymark@reddit
No.
Chemical-Fault-7331@reddit
I mean, people do use Typescript.
simon-brunning@reddit
Even more no. No++.
Sensitive_One_425@reddit
No+++