8000 gh-90117: handle dict and mapping views in pprint by devdanzin · Pull Request #30135 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-90117: handle dict and mapping views in pprin 8000 t #30135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 45 commits into from
May 20, 2025
Merged
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
f7835ca
Teach pprint about dict views with PrettyPrinter._pprint_dict_view an…
devdanzin Dec 16, 2021
1eda2d5
Merge branch 'main' of https://github.com/python/cpython into pprint_…
devdanzin Dec 17, 2021
9500a74
Use _private names for _dict_*_view attributes of PrettyPrinter.
devdanzin Dec 17, 2021
653cdea
Use explicit 'items' keyword when calling _pprint_dict_view from _ppr…
devdanzin Dec 18, 2021
884f224
📜🤖 Added by blurb_it.
blurb-it[bot] Dec 18, 2021
48be1e9
Properly indent code.
devdanzin Jan 19, 2022
9745491
WIP: Improve tests and make short views sortable.
devdanzin Jan 19, 2022
7edb29d
fix typo
merwok Apr 24, 2022
7d2fa0f
Merge branch 'main' into pprint_dict_view
merwok Apr 24, 2022
32773ce
Merge branch 'main' into pprint_dict_view
arhadthedev Mar 4, 2023
15dd266
Address the failing Docs check
arhadthedev Mar 4, 2023
6898bc4
Merge branch 'python:main' into pprint_dict_view
devdanzin Apr 6, 2024
67e3f14
Add tests for collections.abc.[Keys|Items|Mapping|Values]View support…
devdanzin Apr 7, 2024
65e0be2
Add support for collections.abc.[Keys|Items|Mapping|Values]View in pp…
devdanzin Apr 7, 2024
c91af09
Split _pprint_dict_view into _pprint_abc_view, so pretty-printing nor…
devdanzin Apr 7, 2024
5b2341c
Simplify redundant code.
devdanzin Apr 7, 2024
a9ff3df
Add collections.abc views to some existing pprint tests.
devdanzin Apr 7, 2024
4c67166
Remove TODO.
devdanzin Apr 7, 2024
bfa9868
Test that views from collection.UserDict are correctly formatted by p…
devdanzin Apr 7, 2024
148b469
Handle recursive dict and ABC views.
devdanzin Apr 7, 2024
34abce7
Test that subclasses of ABC views work in pprint.
devdanzin Apr 7, 2024
09839a6
Test dict views coming from collections.Counter.
devdanzin Apr 7, 2024
091c3bb
Test ABC views coming from collections.ChainMap.
devdanzin Apr 7, 2024
29655a0
Test odict views coming from collections.OrderedDict.
devdanzin Apr 7, 2024
7ecb456
Merge branch 'main' into pprint_dict_view
devdanzin Apr 8, 2024
646816a
Rename _pprint_abc_view to _pprint_mapping_abc_view.
devdanzin Apr 8, 2024
7537a52
Add pprint test for mapping ABC views where ._mapping has a custom __…
devdanzin Apr 9, 2024
7a6769d
When a mapping ABC view has a ._mapping that defines a custom __repr_…
devdanzin Apr 9, 2024
7dcb9cf
Merge branch 'python:main' into pprint_dict_view
devdanzin Apr 9, 2024
06babe4
Merge remote-tracking branch 'refs/remotes/origin/pprint_dict_view' i…
devdanzin Apr 9, 2024
58692d2
Add tests for ABC mapping views subclasses that don't replace __repr_…
devdanzin Apr 21, 2024
8e605c1
Simplify the pretty printing of ABC mapping views.
devdanzin Apr 21, 2024
7e27e02
Merge branch 'python:main' into pprint_dict_view
devdanzin Apr 21, 2024
eb66934
Merge remote-tracking branch 'refs/remotes/origin/pprint_dict_view' i…
devdanzin Apr 21, 2024
1dc4ab2
Add a test for depth handling when pretty printing dict views.
devdanzin Apr 21, 2024
f267452
Fix checking whether the view type is a subclass of an items view, ad…
devdanzin Apr 22, 2024
3867338
Move construction of the views __repr__ set out of _safe_repr.
devdanzin Apr 26, 2024
1a609d0
Merge branch 'main' into pprint_dict_view
devdanzin Apr 26, 2024
bca6f6f
Merge remote-tracking branch 'refs/remotes/origin/pprint_dict_view' i…
devdanzin Apr 26, 2024
d020f86
Merge branch 'python:main' into pprint_dict_view
devdanzin May 21, 2024
ee7b521
Merge branch 'python:main' into pprint_dict_view
devdanzin May 30, 2024
7009887
Merge branch 'python:main' into pprint_dict_view
devdanzin Jul 1, 2024
9499115
Merge branch 'main' into pprint_dict_view
devdanzin Oct 29, 2024
692c0cd
Merge branch 'main' into pprint_dict_view
AA-Turner Apr 20, 2025
90e069c
Merge branch 'main' into pprint_dict_view
gpshead May 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Test that subclasses of ABC views work in pprint.
  • Loading branch information
devdanzin committed Apr 7, 2024
commit 34abce71c667554c999b7b6b0b86f2053f4a6e86
14 changes: 14 additions & 0 deletions Lib/test/test_pprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ class dict_custom_repr(dict):
def __repr__(self):
return '*'*len(dict.__repr__(self))

class mappingview_custom_repr(MappingView):
def __repr__(self):
return '*'*len(MappingView.__repr__(self))

class keysview_custom_repr(KeysView):
def __repr__(self):
return '*'*len(KeysView.__repr__(self))

@dataclasses.dataclass
class dataclass1:
field1: str
Expand Down Expand Up @@ -283,6 +291,12 @@ def test_container_repr_override_called(self):
dict_custom_repr(),
dict_custom_repr({5: 6}),
dict_custom_repr(zip(range(N),range(N))),
mappingview_custom_repr({}),
mappingview_custom_repr({5: 6}),
mappingview_custom_repr(dict(zip(range(N),range(N)))),
keysview_custom_repr({}),
keysview_custom_repr({5: 6}),
keysview_custom_repr(dict(zip(range(N),range(N)))),
):
native = repr(cont)
expected = '*' * len(native)
Expand Down
0