Comments (1)
Looks like author does not want this in their library #194 (there are a few of those such issues) which is unfortunate because it's a major drawback.
I get the scope argument, but honestly, the whole point of dacite is to serialize, and when I'm getting data from scraping with camelCase, snake_case, and NeitherCase I want to be able to serialize to a standard, instead of having dataclass definitions like this, which are absurd:
@dataclass
class User:
name: str
birthDate: str
country_of_origin: str
Author's suggestion is to pre-process the data before putting it into dacite, but that defeats the purpose of using the library. If I'm pre-processing half of the fields for every class, I may as well not use dacite.
Similar library really hits the nail on the coffin. I've moved over to this one instead. For others with the same issue, I recommend looking into it: https://github.com/Fatal1ty/mashumaro#alias-option
That library took about 10m to convert my types to, but worth it.
from dacite.
Related Issues (20)
- Regression with nested classes
- Tuple of mixed values from list of strings HOT 1
- Type hooks applied to deserialized values when hook for union type is defined
- Return value of custom type hook is discarded when decoding generic type in union
- Regression in recognizing the type of the dataclass in case of inheritance HOT 1
- Mapping key names to class attributes HOT 2
- With strict_unions_match, KeyError is raised instead of UnionMatchError HOT 3
- missing pypi source tarball for 1.8.1 release HOT 3
- Subsequent calls of from_dict on dataclasses that contain Optional[type] and type | None breaks behaviour because of caching HOT 1
- Add missing value factory for from_dict()
- dict cannot be matched if keys are specified as enums in dataclass HOT 3
- Using dacite fails at runtime with pkg_resources.DistributionNotFound HOT 2
- DefaultValueNotFoundError for Optional fields
- `strict_union_match` shadows the Error raised in `__post_init__`
- ValueError: dictionary update sequence element #0 has length 1; 2 is required HOT 1
- from_dict resets `dataclasses.field` with argument `init=False` and `default_factory` HOT 1
- Dacite will put an `int` into an `Optional[float]` field but not a `float | None` field.
- Should it work with Dict[sometype, sometype]?
- Add support for Python 3.12 HOT 2
- dataclass does not accept union of dataclasses?
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 dacite.