compliance-trestle
compliance-trestle copied to clipboard
`allow_population_by_field_name = True` should be added to more generated types for better tooling (e.g. mypy) support
Describe the bug
The following python file is reported as an error when using additional python static checking such as mypy
. This also prevents IDE autocomplete from working for some combination of Python support:
# test.py
from uuid import uuid4
from trestle.oscal.common import InventoryItem
item = InventoryItem(
uuid=str(uuid4()),
description="an item",
props=[],
links=[],
responsible_parties=[],
implemented_components=[],
)
❯❯❯ mypy test.py
test.py:4: error: Unexpected keyword argument "responsible_parties" for "InventoryItem"; did you mean "responsible-parties"? [call-arg]
test.py:4: error: Unexpected keyword argument "implemented_components" for "InventoryItem"; did you mean "implemented-components"? [call-arg]
Found 2 errors in 1 file (checked 1 source file)
This is likely because allow_population_by_field_name = True
is not set in the config of all generated types that have aliases that include -
.
To Reproduce
- Install compliance-trestle
- Install mypy
- Run
mypy
on a file with the above contents.
Expected behavior
Mypy should not report an error.
Screenshots / Logs.
If applicable, add screenshots to help explain your problem.
Environment
- OS: [e.g. iOS]
- Python version:
- Installed packages:
mypy 1.7.1 (compiled: yes)