> by auto-generating python types I'm assuming you are using a code generator? My understanding is that as MyPy is a static analyser there is no way to automatically create types at runtime (which is actually super annoying, particularly for a language as dynamic as Python).
Show HN: Prisma Python – A fully typed ORM for Python
21–30 of 91 posts
Re: Show HN: Prisma Python – A fully typed ORM for Python
#22From [1]: "SQLModel is a library for interacting with SQL databases from Python code, with Python objects. It is designed to be intuitive, easy to use, highly compatible, and robust.
SQLModel is based on Python type annotations, and powered by Pydantic and SQLAlchemy."
Re: Show HN: Prisma Python – A fully typed ORM for Python
#23Seems to solve the same problem as SQLModel. From [1]: "SQLModel is a library for interacting with SQL databases from Python code, with Python objects. It is designed to be intuitive, easy to use, highly compatible, and robust. SQLModel is based on Python type annotations, and powered by Pydantic and SQLAlchemy." [1] https://sqlmodel.tiangolo.com/
Re: Show HN: Prisma Python – A fully typed ORM for Python
#24> by auto-generating python types I'm assuming you are using a code generator? My understanding is that as MyPy is a static analyser there is no way to automatically create types at runtime (which is actually super annoying, particularly for a language as dynamic as Python).
You can create Python types at runtime, and Python’s runtime type checking features predate it's static analyzers. Unfortunately, the additional kinds of objects used for typechecking in the static analyzers (beyond those which are also runtime types) don’t work with runtime type checking, nor do static type declarations (even using types that are also runtime types.) (And, obviously, AOT static analyzers can’t make…
Re: Show HN: Prisma Python – A fully typed ORM for Python
#25This looks promising. Using prisma both in TypeScript app backends and in Python data pipelines would make switching between the two without much cognitive overhead much easier. I'll probably oppose introducing a different Python ORM at work until Prisma Python reaches 1.0
Thanks :) Yeah that is understandable, it is being successfully used in production but it is safer to use a more stable ORM for mission critical products. If you don't want to have to duplicate your model definitions you could write a custom Prisma Generator to generate models for a different Python ORM. https://prisma-client-py.readthedocs.io/en/stable/reference/...
Re: Show HN: Prisma Python – A fully typed ORM for Python
#26> by auto-generating python types I'm assuming you are using a code generator? My understanding is that as MyPy is a static analyser there is no way to automatically create types at runtime (which is actually super annoying, particularly for a language as dynamic as Python).
You can create Python types at runtime, and Python’s runtime type checking features predate it's static analyzers. Unfortunately, the additional kinds of objects used for typechecking in the static analyzers (beyond those which are also runtime types) don’t work with runtime type checking, nor do static type declarations (even using types that are also runtime types.) (And, obviously, AOT static analyzers can’t make…
It unfortunately leaves you with a choice of either taking advantage of dynamic annotations or using MyPy, but not both.
And as the sibling comment says, typescript did it so much better.
Re: Show HN: Prisma Python – A fully typed ORM for Python
#27Re: Show HN: Prisma Python – A fully typed ORM for Python
#28@propbablyrobert great job on this! I hope you can get buy-in from the Prisma team for support. This would be great for their moat.
Re: Show HN: Prisma Python – A fully typed ORM for Python
#29Earlier quoted context omitted.
You can create Python types at runtime, and Python’s runtime type checking features predate it's static analyzers. Unfortunately, the additional kinds of objects used for typechecking in the static analyzers (beyond those which are also runtime types) don’t work with runtime type checking, nor do static type declarations (even using types that are also runtime types.) (And, obviously, AOT static analyzers can’t make…
Exactly, it’a brilliant that they designed a system where the annotations themselves can be dynamic and read at runtime, it has so much potential for interesting things. But MyPy completely hobbles it by preventing all the dynamic potential, even if MyPy had an escape hatch to say ignore anything derived from this type as it’s not possible to describe statically that would be better than nothing. It unfortunately lea…
```py
from typing import TYPE_CHECKING
if TYPE_CHECKING:
Foo = "expression that mypy can understand"
else:
Foo = "dynamic expression"
```Re: Show HN: Prisma Python – A fully typed ORM for Python
#30Earlier quoted context omitted.
You can create Python types at runtime, and Python’s runtime type checking features predate it's static analyzers. Unfortunately, the additional kinds of objects used for typechecking in the static analyzers (beyond those which are also runtime types) don’t work with runtime type checking, nor do static type declarations (even using types that are also runtime types.) (And, obviously, AOT static analyzers can’t make…
Yes it is rather unfortunate, Python's typing system doesn't support dynamically creating types like you can in TypeScript :/
Could you explain what you mean by this? I'm not clear on what typescript behavior this describes.