- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 258
Description
Describe the bug
If a schema has type: object, properties: {}, and additionalProperties: false, schema parsing succeeds and the generator generates appropriate code... but it fails in the post-generation linting step, with an error like this:
empty_object_example_client/models/get_example_response_200.py:25:9: F841 Local variable `d` is assigned to but never used
   |
23 |     @classmethod
24 |     def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
25 |         d = src_dict.copy()
   |         ^ F841
26 |         get_example_response_200 = cls(
27 |         )
The problem is that the template assumes it'll be doing something with d— either reading specific named properties out of it, or saving any unrecognized ones as "additional". But in this case neither of those things can happen, so d is unused.
OpenAPI Spec File
A link to an OpenAPI document which produces this issue. Ideally, write a minimal reproduction only containing the problematic pieces.
https://gist.github.com/eli-bl/0e433b0dcde331bddff2842f2b6633d2
Desktop (please complete the following information):
- OS: MacOS 14.5
- Python Version: 3.8.15
- openapi-python-client version: 0.21.4
Additional context
This may seem like a contrived example, but I have seen API scenarios where an empty object is actually the desired value.