Skip to content

Conversation

@zenlyj
Copy link
Contributor

@zenlyj zenlyj commented Nov 1, 2025

Type of Changes

Type
βœ“ πŸ› Bug fix
✨ New feature
πŸ”¨ Refactoring
πŸ“œ Docs

Description

The consider-using-assignment-expr check should ignore cases where a variable annotation statement is represented as an AnnAssign node without an assigned value.

Closes #10707

@zenlyj zenlyj requested a review from cdce8p as a code owner November 1, 2025 14:21
@github-actions
Copy link
Contributor

github-actions bot commented Nov 1, 2025

πŸ€– According to the primer, this change has no effect on the checked open source code. πŸ€–πŸŽ‰

This comment was generated for commit 9b67845

@codecov
Copy link

codecov bot commented Nov 1, 2025

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 95.97%. Comparing base (f8f6ccd) to head (9b67845).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #10714   +/-   ##
=======================================
  Coverage   95.97%   95.97%           
=======================================
  Files         176      176           
  Lines       19537    19539    +2     
=======================================
+ Hits        18750    18752    +2     
  Misses        787      787           
Files with missing lines Coverage Ξ”
pylint/extensions/code_style.py 100.00% <100.00%> (ΓΈ)
πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zenlyj zenlyj changed the title Fix crash for consider-using-assignment-expr when a variable annotation without assignment is used as the if test expression Fix crash when a variable annotation used as the if test expression Nov 1, 2025
@zenlyj zenlyj changed the title Fix crash when a variable annotation used as the if test expression Fix crash when a variable annotation is used as the if test expression Nov 1, 2025
@zenlyj zenlyj changed the title Fix crash when a variable annotation is used as the if test expression Fix crash when a variable annotation is used as if test expression Nov 1, 2025
@Pierre-Sassoulas Pierre-Sassoulas added this to the 4.0.3 milestone Nov 3, 2025
Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

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

Just a question, LGTM otherwise.

Comment on lines +275 to +277
# Should ignore variable annotation without assignment
if prev_sibling.value is None:
return
Copy link
Member

Choose a reason for hiding this comment

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

Should it be directly in _check_prev_sibling_to_if_stmt ?

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttributeError: 'NoneType' object has no attribute 'as_string' in code_style checker

3 participants