Comments (3)
See lovasoa/marshmallow_dataclass#186 for a solution to a similar problem.
Personally I never do this import because it has caused problems in the past with other libraries but I would be willing to accept a PR that addresses this.
from argparse_dataclass.
I encountered the same issue.
By patching argparse_dataclass.fields()
based on @isbadawi's idea, I could solve the error.
from __future__ import annotations
from dataclasses import fields
import argparse_dataclass
from typing import get_type_hints
def _patch_fields(cls, *args, **kwargs):
t = get_type_hints(cls)
def _update(_f):
_f.type = t[_f.name]
return _f
return tuple(_update(f) for f in fields(cls, *args, **kwargs))
argparse_dataclass.fields = _patch_fields
@argparse_dataclass.dataclass
class MyArgs:
foo: int = 0
bar: str = 'hello'
baz: bool = False
def main():
print(MyArgs.parse_args())
if __name__ == '__main__':
main()
MyArgs(foo=0, bar='hello', baz=False)
from argparse_dataclass.
@mivade
Thank you for your reply.
I sent PR (#51).
from argparse_dataclass.
Related Issues (20)
- Add linting step to tests HOT 1
- Needs explicit type in metadata for Optional[type] fields HOT 1
- Release version 1.0.0 HOT 2
- Document adding help text to command-line arguments HOT 3
- Default help formatter is not working HOT 1
- Is nested dataclass supported? HOT 3
- Is dict type supported? HOT 2
- Option to keep underscores in arguments names HOT 2
- Do you want to publish it in Pypi ? HOT 3
- Switch to pyproject.toml HOT 1
- Automate publishing releases on PyPI
- Drop support for Python 3.6, 3.7 HOT 2
- Support Union types again HOT 1
- Update documentation to include union type examples
- Field metadata being passed on to parser needs documentation HOT 3
- Support Argument groups HOT 4
- Modernize packaging HOT 1
- Update Manifest
- make _add_dataclass_options public HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from argparse_dataclass.