Skip to content

Explicitly re-export types in models/__init__.py #540

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

Closed
johnthagen opened this issue Nov 22, 2021 · 1 comment
Closed

Explicitly re-export types in models/__init__.py #540

johnthagen opened this issue Nov 22, 2021 · 1 comment
Labels
✨ enhancement New feature or improvement
Milestone

Comments

@johnthagen
Copy link
Collaborator

Describe the bug

In the generated client, the models/__init__.py looks something like:

""" Contains all the data models used in inputs/outputs """

from .type import Type

This makes it convenient to do:

from models import Type

But this is missing adding the types to __all__ to properly mark them as exported:

""" Contains all the data models used in inputs/outputs """

from .type import Type

__all__ = ["Type"]

Without this, mypy --strict throws the following errors:

error: Module "pcb_dr_api_client.models" does not explicitly export attribute "Type"; implicit reexport disabled

See: https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-no-implicit-reexport

Expected behavior

No errors in usage when mypy --strict is used for this kind of import.

Desktop (please complete the following information):

  • OS: macOS 10.15.7
  • Python Version: 3.9.8
  • openapi-python-client version: 0.10.7
@johnthagen johnthagen added the 🐞bug Something isn't working label Nov 22, 2021
@dbanty dbanty changed the title Generated models/__init__.py does not explicitly re-export types Explicitly re-export types in models/__init__.py Jan 29, 2022
@dbanty dbanty added ✨ enhancement New feature or improvement and removed 🐞bug Something isn't working labels Jan 29, 2022
@dbanty dbanty added this to the 0.12.0 milestone Sep 26, 2022
@dbanty
Copy link
Collaborator

dbanty commented Sep 26, 2022

#676 implements this 🥳

@dbanty dbanty closed this as completed Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or improvement
Projects
None yet
Development

No branches or pull requests

2 participants