Quick question: is `prefect_aws` typed? It doesn't...
# ask-community
n
Quick question: is
prefect_aws
typed? It doesn't seem to have a py.typed file.
a
Most of the core objects are pydantic models, so should be typed. Can’t speak for every utility function though
n
Right, but if the package doesn't contain the py.typed marker file then type checkers don't respect any of the given types. I can make it work with
touch .venv/lib/python3.12/site-packages/prefect_aws/py.typed
, but y'know
a
Heh should read your OG comment closer. Seems like an oversight to me
n
FWIW I was in this community 2 years ago when I worked at a different company and I think this was my first message in the slack at that time but about the core prefect package. Apparently I'm that guy that shows up to complain about type checking haha
❤️ 1
a
Haha half the issues I leave on our repo is about fixing types so we’re in the same boat
Any other typing asks while we’re talking?
n
I mean since you asked... I use pyright in strict mode with as few disabling flags as possible. In that setup,
from prefect import flow
is an error, because flow is "partially unknown" It's due to some pretty ticky-tacky stuff, such as an unconstrained
dict
type (no key or value type constraints), but it's all the same to strict-mode-pyright
It's not so much an "ask", since I understand that the solution is to turn on strict mode in your CI and then suffer for all eternity while you hunt down 3,062 new type checking errors.. but just something I thought I'd flag
Maybe it's one of those things an LLM can submit a PR for one day 😄
a
I think we cleaned up literally 1500+ errors like this in the last week. I think all client and server models are behaving now? @Nate is tackling our settings next which is another huge source of typing anguish. After that should just be our top level primitives to type, which gets a lot easier once Pydantic’s validate_call respects typing.Unpack in their next release. 🤞
👍 1
n
Oh that's awesome. Just FYI I can get around it with
reportUnknownMemberType = false
and
reportUnknownVariableType = false
, so not the end of the world. But I'll definitely keep an eye out for the day that I can remove those flags
a
Image from iOS.jpg
n
https://github.com/PrefectHQ/prefect/blob/main/src/prefect/utilities/asyncutils.py#L345-L347
Copy code
untyped_credentials = await AwsCredentials.load("my-credentials")  # type: ignore
    credentials = cast(AwsCredentials, untyped_credentials)
    content = await s3_download(bucket="my-bucket", key="test.txt", aws_credentials=credentials)
I appreciate the sync/async compatibility but damn