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

Adding type hints to class level in SwaggerClient subclass #8

Open
voneiden opened this issue Feb 17, 2022 · 2 comments
Open

Adding type hints to class level in SwaggerClient subclass #8

voneiden opened this issue Feb 17, 2022 · 2 comments

Comments

@voneiden
Copy link

voneiden commented Feb 17, 2022

Would there be any unwanted side effects in adding type annotations to the class level in the template?

class ${config.client_type}(bravado.client.SwaggerClient):

class ${config.client_type}(bravado.client.SwaggerClient):
% for resource in spec.resources:
    ${resource.name}: ${config.resource_type(resource.name)}
% endfor
    def __init__(self, swagger_spec: bravado_core.spec.Spec,
                 also_return_response: bool = False) -> None:

Backstory: It seems Intellij based editors fail to register types defined in subclass init method unless a value is assigned.

@nickgaya
Copy link
Owner

This project uses MyPy as the reference type-checker. I believe my original intent with declaring the attributes inside the __init__ method is to mark them as instance attributes that should not be accessed via the class. But since MyPy does not distinguish between these (see python/mypy#240), I would be fine with moving these declarations to the class level for greater compatibility with IntelliJ.

However I am no longer actively maintaining this project, and many of the tests are now failing which would need to be fixed before adding any new features.

@voneiden
Copy link
Author

However I am no longer actively maintaining this project, and many of the tests are now failing which would need to be fixed before adding any new features.

Understandable. Bravado itself seems to be going a bit slow too. Say, as an expert of sorts in this area, is there any alternative you would advocate today to achieve similar results? Just swagger codegen?

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

2 participants