Skip to content

Conversation

emmanuel-ferdman
Copy link
Contributor

Type of Changes

Type
🐛 Bug fix

Description

This PR fixes a false positive in the inconsistent-return-statements checker where functions using quit() or exit() were incorrectly flagged as having inconsistent returns The fix leverages the existing utils.is_terminating_func() utility that already recognizes _sitebuiltins.Quitter (the type of quit/exit objects) as terminating.

Example:

import sys

def func1(i):
    if i == 1:
        return i
    sys.exit(1)  # `inconsistent-return-statements` not raised

Closes #10508

emmanuel-ferdman and others added 2 commits September 20, 2025 15:36
…t()`/`exit()`

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
@Pierre-Sassoulas Pierre-Sassoulas added False Positive 🦟 A message is emitted but nothing is wrong with the code backport maintenance/3.3.x labels Sep 20, 2025
@Pierre-Sassoulas Pierre-Sassoulas added this to the 3.3.9 milestone Sep 20, 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.

LGTM, elegant fix, loads of tests, thank you !

Copy link

codecov bot commented Sep 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.90%. Comparing base (ed6b306) to head (3a2f5f1).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #10572   +/-   ##
=======================================
  Coverage   95.90%   95.90%           
=======================================
  Files         176      176           
  Lines       19456    19458    +2     
=======================================
+ Hits        18659    18661    +2     
  Misses        797      797           
Files with missing lines Coverage Δ
pylint/checkers/refactoring/refactoring_checker.py 98.19% <100.00%> (+<0.01%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

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

This comment was generated for commit 3a2f5f1

@Pierre-Sassoulas Pierre-Sassoulas merged commit e694467 into pylint-dev:main Sep 20, 2025
48 checks passed
@pylint-backport
Copy link
Contributor

The backport to maintenance/3.3.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.3.x maintenance/3.3.x
# Navigate to the new working tree
cd .worktrees/backport-maintenance/3.3.x
# Create a new branch
git switch --create backport-10572-to-maintenance/3.3.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 e694467ce0754d7b051b1b868820802cb1496703
# Push it to GitHub
git push --set-upstream origin backport-10572-to-maintenance/3.3.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-maintenance/3.3.x

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

Pierre-Sassoulas pushed a commit that referenced this pull request Sep 20, 2025
…t()`/`exit()` (#10572)

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
Pierre-Sassoulas added a commit that referenced this pull request Sep 20, 2025
…t()`/`exit()` (#10572) (#10573)

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
Co-authored-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport maintenance/3.3.x 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.

Inconsistent report of inconsistent-return-statements when using exit / quit
2 participants