Skip to content

Commit db7a064

Browse files
dorcohedbanty
andauthored
add missing import to model template (#1072)
My first pull request in this repo. I'm still learning the UTs. I found that if I have a literal with a default value, the code uses cast without importing it from typing. I'm still learning the UTs on this. Do you think I should open an issue? --------- Co-authored-by: Dylan Anthony <[email protected]> Co-authored-by: Dylan Anthony <[email protected]>
1 parent e4128ac commit db7a064

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
default: patch
3+
---
4+
5+
# Add missing `cast` import when using `const`
6+
7+
Fixed by PR #1072. Thanks @dorcohe!

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ dmypy.json
2424
# JetBrains
2525
.idea/
2626

27+
# Visual Studio Code
28+
.vscode/
29+
2730
test-reports/
2831

2932
/coverage.xml

openapi_python_client/parser/properties/const.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,6 @@ def get_imports(self, *, prefix: str) -> set[str]:
115115
if self.required:
116116
return {"from typing import Literal"}
117117
return {
118-
"from typing import Literal, Union",
118+
"from typing import Literal, Union, cast",
119119
f"from {prefix}types import UNSET, Unset",
120120
}

0 commit comments

Comments
 (0)