FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

propertize Callable attributes before freezing dataclasses by uSpike · Pull Request #12383 · python/mypy · GitHub

Repository navigation

propertize Callable attributes before freezing dataclasses - #12383

Merged
jhance merged 4 commits into
python:masterfrom
uSpike:12312-dataclass-frozen-callable
Mar 29, 2022
Merged

jhance merged 4 commits into
python:masterfrom
uSpike:12312-dataclass-frozen-callable

Conversation

uSpike commented Mar 19, 2022 •
edited
Loading

Copy link
Copy Markdown
Contributor

Description

Fixes: #12312

Related: #10292

Callable attributes of a frozen=True dataclass were not being handled correctly: Callable attributes were being propertized if the dataclass was not frozen.

This change will always propertize Callable attributes before optionally freezing attributes in the dataclass plugin.

Test Plan

Added a test for Callable types in a frozen dataclass to test-data/unit/check-dataclasses.test

This comment has been minimized.

uSpike commented Mar 21, 2022

Copy link
Copy Markdown
Contributor Author

I need to rethink this because this does not raise an error when a frozen dataclass Callable method is mutated.

uSpike commented Mar 21, 2022

Copy link
Copy Markdown
Contributor Author

OK I think I've fixed it so that propertized callables are not writable when frozen. This PR should be ready for review

uSpike commented Mar 21, 2022

Copy link
Copy Markdown
Contributor Author

Fixed linting error

This comment has been minimized.

1 similar comment

This comment has been minimized.

jhance commented Mar 23, 2022

Copy link
Copy Markdown
Collaborator

Needs a rebase then I will merge.

Copy link
Copy Markdown
Member

I fixed the merge conflict

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

jhance merged commit a33d235 into python:master Mar 29, 2022
uSpike deleted the 12312-dataclass-frozen-callable branch March 29, 2022 18:00
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Callable types are not handled correctly in frozen dataclasses

3 participants


Back | FazBrowse Home | New Git URL