Sitelet https://github.com/pylint-dev/pylint/pull/9782
Skip to content

Handle assert_never() when imported from typing_extensions - #9782

Merged
Pierre-Sassoulas merged 4 commits into
mainfrom
assert-never-typing-ext
Jul 12, 2024
Merged

Pierre-Sassoulas merged 4 commits into
mainfrom
assert-never-typing-ext

Conversation

@jacobtylerwalls

Copy link
Copy Markdown
Member

Type of Changes

Type
✓ 🐛 Bug fix

Description

Closes #9780

@jacobtylerwalls jacobtylerwalls added False Positive 🦟 A message is emitted but nothing is wrong with the code backport maintenance/4.1.x labels Jul 9, 2024
@jacobtylerwalls jacobtylerwalls added this to the 3.2.6 milestone Jul 9, 2024
@github-actions

This comment has been minimized.

@codecov

codecov Bot commented Jul 9, 2024 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.81%. Comparing base (52fe657) to head (3ace500).
⚠️ Report is 550 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #9782   +/-   ##
=======================================
  Coverage   95.81%   95.81%           
=======================================
  Files         174      174           
  Lines       18860    18860           
=======================================
+ Hits        18070    18071    +1     
+ Misses        790      789    -1     
Files with missing lines Coverage Δ
pylint/checkers/variables.py 97.23% <100.00%> (+0.07%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

This comment has been minimized.

DanielNoord
DanielNoord previously approved these changes Jul 9, 2024

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Élégant fix, I like when we remove complexity and fix bugs at the same time it's surprisingly often happening too. Just a nit.


from pylint.constants import PY311_PLUS

if PY311_PLUS:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should use sys.version_info directly here. Importing from pylint create coupling so more maintenance work when we drop python 3.11 and more importantely code in the wild will never import out internal constants so it makes functional tests less likely to be representative of real code.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Why is it Less maintenance?

@Pierre-Sassoulas Pierre-Sassoulas Jul 9, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We'll have to modify this when we drop python 3.11 and the constant does not exists anymore, right ?

@jacobtylerwalls jacobtylerwalls Jul 9, 2024 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, but I was suggesting it was the same whether we use the constant or the version guard. The last times we dropped versions we also removed version guards.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a functional test, I don't think functional test should look like internal pylint code. However it's not really important, let's move on

@github-actions

github-actions Bot commented Jul 9, 2024

Copy link
Copy Markdown
Contributor

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

This comment was generated for commit 3ace500

@Pierre-Sassoulas
Pierre-Sassoulas merged commit a48cd4c into main Jul 12, 2024
@Pierre-Sassoulas
Pierre-Sassoulas deleted the assert-never-typing-ext branch July 12, 2024 10:09
@github-actions

Copy link
Copy Markdown
Contributor

The backport to maintenance/3.2.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-maintenance/3.2.x maintenance/3.2.x
# Navigate to the new working tree
cd .worktrees/backport-maintenance/3.2.x
# Create a new branch
git switch --create backport-9782-to-maintenance/3.2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 a48cd4c6a872b6565bc58030b74585812f327f36
# Push it to GitHub
git push --set-upstream origin backport-9782-to-maintenance/3.2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-maintenance/3.2.x

Then, create a pull request where the base branch is maintenance/3.2.x and the compare/head branch is backport-9782-to-maintenance/3.2.x.

This branch was previously deployed

1 inactive deployment
Backport — 3ace5009 Deployed Oct 12, 2025 by Pierre-Sassoulas via Backport #4990
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backported False Positive 🦟 A message is emitted but nothing is wrong with the code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

possibly-used-before-assignment does not treat assert_never the same when imported from typing_extensions

3 participants