Skip to content

Suggest using prop-decorator error code to ignore mypy errors with @computed_field#11547

Merged
Viicos merged 1 commit intopydantic:mainfrom
joren485:mypy-prop-decorator
Mar 13, 2025
Merged

Suggest using prop-decorator error code to ignore mypy errors with @computed_field#11547
Viicos merged 1 commit intopydantic:mainfrom
joren485:mypy-prop-decorator

Conversation

@joren485
Copy link
Copy Markdown
Contributor

@joren485 joren485 commented Mar 13, 2025

Change Summary

For property decorators, # type: ignore[prop-decorator] is the correct type ignore comment in Mypy, # type: ignore[misc] should only be used for backward compatibly.

Checklist

  • The pull request title is a good summary of the changes - it will be used in the changelog
  • Unit tests for the changes exist
  • Tests pass on CI
  • Documentation reflects the changes where applicable
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

Selected Reviewer: @sydney-runkle

@github-actions github-actions Bot added the relnotes-fix Used for bugfixes. label Mar 13, 2025
@github-actions
Copy link
Copy Markdown
Contributor

Coverage report

This PR does not seem to contain any modification to coverable code.

@joren485
Copy link
Copy Markdown
Contributor Author

please review

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Mar 13, 2025

CodSpeed Performance Report

Merging #11547 will not alter performance

Comparing joren485:mypy-prop-decorator (e4c76e8) with main (10af6a8)

Summary

✅ 46 untouched benchmarks

Copy link
Copy Markdown
Member

@Viicos Viicos left a comment

Choose a reason for hiding this comment

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

Thanks, let's not mention the backwards compatible code, users are strongly encouraged to update their type checker version.

@Viicos Viicos added awaiting author response awaiting response from issue opener and removed ready for review labels Mar 13, 2025
@Viicos Viicos added relnotes-ignore Omit this PR from the release notes. and removed relnotes-fix Used for bugfixes. awaiting author response awaiting response from issue opener labels Mar 13, 2025
@Viicos Viicos changed the title Document the narrowest type ignore comment for property decorators Suggest using prop-decorator error code to ignore mypy errors with @computed_field Mar 13, 2025
@Viicos Viicos merged commit b9fb3f1 into pydantic:main Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

relnotes-ignore Omit this PR from the release notes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants