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
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
#1143 added
typeas a reserved field name becausetypeis used in type annotations, which renames OpenAPI fields with the nametypetotype_.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,
matchwas added a soft keyword so that anyone usingmatchas a local variable name would not be affected.Beta Was this translation helpful? Give feedback.
All reactions