Revert type
as a reserved field name
#1191
johnthagen
started this conversation in
Feature request
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
#1143 added
type
as a reserved field name becausetype
is used in type annotations, which renames OpenAPI fields with the nametype
totype_
.openapi-python-client/openapi_python_client/utils.py
Line 59 in 718e9aa
This leads to extra confusion for users of the client because this common field name no longer matches the API spec.
The rationale given in #1143 (comment) was that this is due to local variable names, but Python supports shadowing (for built ins as well, such as
type
), to support this very reason. For example this code runs fine on Python 3.9+:Output:
1: <class 'int'>
At a higher level, the Python core team makes a big effort to avoid these kinds of breaking changes that affect variable naming. For example, when pattern matching was added,
match
was added a soft keyword so that anyone usingmatch
as a local variable name would not be affected.Beta Was this translation helpful? Give feedback.
All reactions