Skip to content
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

Ignore dataclass.__replace__ LSP violations #18464

Merged
merged 1 commit into from
Jan 14, 2025

Conversation

cdce8p
Copy link
Collaborator

@cdce8p cdce8p commented Jan 14, 2025

Refining dataclass attributes with a narrower type has historically been accepted. Mypy shouldn't emit an LSP warning for the synthesized __replace__ method added in Python 3.13 either.

Users are instead encouraged to enable --enable-error-code mutable-override to highlight potential issues.

Fixes #18216

This comment has been minimized.

@cdce8p cdce8p force-pushed the dataclass-replace-lsp-violation branch from 638cf6c to f53d5ca Compare January 14, 2025 21:09
Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@cdce8p cdce8p requested a review from hauntsaninja January 14, 2025 21:30
@ilevkivskyi ilevkivskyi merged commit 5e119d0 into python:master Jan 14, 2025
18 checks passed
@cdce8p cdce8p deleted the dataclass-replace-lsp-violation branch January 14, 2025 22:46
@cdce8p cdce8p removed the request for review from hauntsaninja January 14, 2025 22:47
@Viicos
Copy link
Contributor

Viicos commented Jan 15, 2025

Thanks @cdce8p

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.

Dataclasses, __replace__ and LSP violations
3 participants