You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
If a property is both nullable and required, It will be defined as Optional, but Optional won't be important leading to a warning during code generation: test-api-client/test_api_client/models/cat.py:11:9: F821 undefined name 'Optional'
To Reproduce
Steps to reproduce the behavior:
+ rm -rf test-api-client
+ openapi-python-client generate --path test.yaml
Generating test-api-client
+ autoflake --in-place --remove-all-unused-imports --remove-unused-variables --expand-star-imports -r test-api-client/
+ isort test-api-client/
+ black test-api-client/
reformatted /Users/daniel/openapi-specs-upstream-repros/test-api-client/test_api_client/models/__init__.py
All done! ✨ 🍰 ✨
1 file reformatted, 7 files left unchanged.
+ flake8 --ignore=E722,E501 test-api-client/
test-api-client/test_api_client/models/cat.py:11:9: F821 undefined name 'Optional'
+ cat test-api-client/test_api_client/models/cat.py
from __future__ import annotations
from dataclasses import dataclass
from typing import Any, Dict
@dataclass
class Cat:
""" """
id: Optional[str]
def to_dict(self) -> Dict[str, Any]:
id = self.id
return {
"id": id,
}
@staticmethod
def from_dict(d: Dict[str, Any]) -> Cat:
id = d["id"]
return Cat(
id=id,
)
Expected behavior Optional should be imported if it is used in a file.
dtkav
changed the title
properties that are both nullable & required use Optional without importing it
Properties that are both nullable & required use Optional without importing it
Sep 4, 2020
Describe the bug
If a property is both nullable and required, It will be defined as Optional, but Optional won't be important leading to a warning during code generation:
test-api-client/test_api_client/models/cat.py:11:9: F821 undefined name 'Optional'
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Optional
should be imported if it is used in a file.OpenAPI Spec File
https://gist.github.com/dtkav/1e40db511a80ca4a545fa4519a8d9adf
Desktop (please complete the following information):
Additional context
Potentially fixed by #177
The text was updated successfully, but these errors were encountered: