Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better support for typing and mypy integration #112

Open
blazing-gig opened this issue Nov 21, 2022 · 5 comments
Open

Better support for typing and mypy integration #112

blazing-gig opened this issue Nov 21, 2022 · 5 comments

Comments

@blazing-gig
Copy link

blazing-gig commented Nov 21, 2022

  • fhir.resources version: 6.4.0
  • Python version: 3.9
  • Operating System: MacOS

Description

from fhir.resources.address import Address
from fhir.resources.patient import Patient

p = Patient.construct()

p.address.append(Address()) # -> This line gives an IDE type error which says it expects an instance of type `AddressType` instead. 

# With mypy the above line errors out

I'd like to understand the thought process behind why the type of Patient.address in the Pydantic base model has been annotated with typing.List[fhirtypes.AddressType] rather than the actual typing.List[fhirtypes.Address]. This would also help make the package compatible with mypy.

@blazing-gig
Copy link
Author

@nazrulworld Would be happy to ideate and contribute if needed. Thanks

@nazrulworld
Copy link
Owner

@blazing-gig please have a look here #58

Any kind of contribution is always welcome 🙏

@blazing-gig
Copy link
Author

Hey @nazrulworld I read through #58 and it seems by and large that this decision was made to circumvent circular deps while defining the models. Is this correct or am I missing something ?

@blazing-gig
Copy link
Author

blazing-gig commented Dec 17, 2022

Hey @nazrulworld could you pls revert to my previous comment ? Coz if circular refs is the only problem, it can be annotated properly using this and made compatible with mypy. I can open a PR for the same if we can come to consensus on this. Thanks!

@imranq2
Copy link

imranq2 commented Jul 6, 2024

Has this been fixed yet? It is super annoying to have mypy errors all over the place and we have to manually cast to get around them...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants