[issue45158] Refactor traceback.py to make TracebackException more extensible.

2021-09-09 Thread Anton Abrosimov
New submission from Anton Abrosimov : 1. Move internal dependencies (`FrameSummary`, `StackSummary`) to class attributes. Reduce coupling. 2. Separate receiving, processing and presenting traceback information. How to replace `repr` with `pformat` in `FrameSummary`? def __init__

[issue45158] Refactor traceback.py to make TracebackException more extensible.

2021-09-09 Thread Anton Abrosimov
Anton Abrosimov added the comment: I think now is a good time for such a change. `FrameSummary`,` StackSummary` and `TracebackException` can be left backward compatible. And PEP 657 already breaks backward compatibility of output parsers

[issue42742] Add abc.Mapping to dataclass

2020-12-25 Thread Anton Abrosimov
New submission from Anton Abrosimov : I want to add `abc.Mapping` extension to `dataclasses.dataclass`. Motivation: 1. `asdict` makes a deep copy of the `dataclass` object. If I only want to iterate over the `field` attributes, I don't want to do a deep copy. 2. `dict(my_dataclass)` c

[issue42742] Add abc.Mapping to dataclass

2020-12-25 Thread Anton Abrosimov
Anton Abrosimov added the comment: Thanks for the answer, I agree. The implementation should be like this? from collections.abc import Mapping from dataclasses import dataclass, fields, _FIELDS, _FIELD class _DataclassMappingMixin(Mapping): def __iter__(self): return (f.name for

[issue42742] Add abc.Mapping to dataclass

2020-12-25 Thread Anton Abrosimov
Anton Abrosimov added the comment: An alternative way: from collections.abc import Mapping from dataclasses import dataclass, fields, _FIELDS, _FIELD class DataclassMappingMixin(Mapping): def __iter__(self): return (f.name for f in fields(self)) def __getitem__(self, key

[issue42742] Add abc.Mapping to dataclass

2020-12-25 Thread Anton Abrosimov
Anton Abrosimov added the comment: I think the second option looks better. More pythonic. No need to create new classes No typing hacks. Mixin can be easily expanded. Yes, I will do refactoring, typing, documentation and tests in PR. -- ___ Python

[issue42742] Add abc.Mapping to dataclass

2020-12-25 Thread Anton Abrosimov
Anton Abrosimov added the comment: This Mixin only works with dataclass objects. And uses the private functionality of the dataclasses. So dataclasses.py is the right place for this. I think I can do enough tests. And I think that this is too little for a standalone project

[issue42742] Add abc.Mapping to dataclass

2020-12-25 Thread Anton Abrosimov
Anton Abrosimov added the comment: Thanks for the good offer, I will definitely use it. -- ___ Python tracker <https://bugs.python.org/issue42742> ___ ___ Pytho

[issue42742] Add abc.Mapping to dataclass

2020-12-29 Thread Anton Abrosimov
Anton Abrosimov added the comment: Link to python-ideas thread: https://mail.python.org/archives/list/python-id...@python.org/thread/XNXCUJVNOOVPAPL6LF627EOCBUUUX2DG/ -- ___ Python tracker <https://bugs.python.org/issue42