Skip to content

gh-141510: Replace MappingProxyType with frozendict#144904

Merged
vstinner merged 5 commits intopython:mainfrom
vstinner:frozendict_mappingproxy
Feb 18, 2026
Merged

gh-141510: Replace MappingProxyType with frozendict#144904
vstinner merged 5 commits intopython:mainfrom
vstinner:frozendict_mappingproxy

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Feb 17, 2026

@vstinner
Copy link
Member Author

Oh, the "Run mypy on Lib/tomllib" job fails with "Name frozendict is not defined" because it runs on an older Python version which doesn't have this new built-in type:

Run mypy --config-file Lib/tomllib/mypy.ini
Lib/tomllib/_parser.py:43: error: Name "frozendict" is not defined 
[name-defined]
    BASIC_STR_ESCAPE_REPLACEMENTS: Final = frozendict(
                                           ^~~~~~~~~~
Found 1 error in 1 file (checked 4 source files)
Error: Process completed with exit code 1.

@vstinner
Copy link
Member Author

I reverted the tomllib change to workaround the mypy issue.

Copy link
Member

@bitdancer bitdancer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving the email change only, I'm not familiar with the other code bases.

@vstinner
Copy link
Member Author

cc @picnixz

Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok for HMAC & other hashlib-related changes (they are only tests and essentially, I wanted an immutable view of a mapping so it serves us well)

@benediktjohannes
Copy link
Contributor

Oh, tests are failing

0:13:17 load avg: 10.90 [1/1/1] test_dataclasses failed (1 failure)
Re-running test_dataclasses in verbose mode (matching: test_field_repr)
test_field_repr (test.test_dataclasses.TestCase.test_field_repr) ... FAIL

FAIL: test_field_repr (test.test_dataclasses.TestCase.test_field_repr)

Traceback (most recent call last):
File "/Users/runner/work/cpython/cpython/Lib/test/test_dataclasses/init.py", line 79, in test_field_repr
self.assertEqual(repr_output, expected_output)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: "Fiel[159 chars]dict(),kw_only=<dataclasses._MISSING_TYPE obje[50 chars]one)" != "Fiel[159 chars]dict({}),kw_only=<dataclasses._MISSING_TYPE ob[52 chars]one)"

@benediktjohannes
Copy link
Contributor

I'll have a look on this as soon as I've got some time

@vstinner
Copy link
Member Author

I updated my branch and I updated test_dataclasses for repr(frozendict) change.

metadata=frozendict({})

I updated repr(frozendict) of empty frozendict to: frozendict() instead of frozendict({}).

@benediktjohannes
Copy link
Contributor

LGTM

@vstinner vstinner enabled auto-merge (squash) February 18, 2026 19:59
@vstinner vstinner merged commit 0bbdb4e into python:main Feb 18, 2026
48 checks passed
@vstinner vstinner deleted the frozendict_mappingproxy branch February 18, 2026 20:23
@vstinner
Copy link
Member Author

Merged. Thanks for reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments