lebrice / SimpleParsing

Simple, Elegant, Typed Argument Parsing with argparse
MIT License
410 stars 52 forks source link

Update global namespaces for postponed annotations #183

Closed zhiruiluo closed 1 year ago

zhiruiluo commented 1 year ago

This PR is to address the issue #168. The PR #182 is revoked based on that this fix can also address issue #181.

The bases of dataclasses in a different module from the module of the child dataclass defined were raising NameError: name "xxx" is not defined for the postponed annotations.

I added a get_global_ns to recursively get the definition of its bases. Also, added test_postponed_annotation.py mentioned in #168.

zhiruiluo commented 1 year ago

@lebrice

zhiruiluo commented 1 year ago

The current commit changed the way of updating global namespaces. Updating the global_ns from the deepest base until where the field_annotation is defined will address the overwriting issue. It passed the Subclass test and all others.

zhiruiluo commented 1 year ago

Why is the flake8 repo for pre-commit on gitlab? And the link is 404.

zhiruiluo commented 1 year ago

Done with the pre-commit check. But, I didn't change the .pre-commit-config.yaml. I am not sure why using gitlab for this, but I did switch to github version of flake8 to continue pre-commit check.