Skip to content

Avoid duplicate overgeneral-exceptions warnings with --jobs #8702

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

Merged
merged 1 commit into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/whatsnew/fragments/7774.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Avoid duplicative warnings for unqualified exception names in the ``overgeneral-exceptions``
setting when running with ``--jobs``.

Closes #7774
13 changes: 0 additions & 13 deletions pylint/checkers/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import builtins
import inspect
import warnings
from collections.abc import Generator
from typing import TYPE_CHECKING, Any

Expand Down Expand Up @@ -307,18 +306,6 @@ class ExceptionsChecker(checkers.BaseChecker):

def open(self) -> None:
self._builtin_exceptions = _builtin_exceptions()
# TODO 3.1: Remove this check and put it elsewhere
for exc_name in self.linter.config.overgeneral_exceptions:
if "." not in exc_name:
warnings.warn_explicit(
f"'{exc_name}' is not a proper value for the 'overgeneral-exceptions' option. "
f"Use fully qualified name (maybe 'builtins.{exc_name}' ?) instead. "
"This will cease to be checked at runtime in 3.1.0.",
category=UserWarning,
filename="pylint: Command line or configuration file",
lineno=1,
module="pylint",
)
super().open()

@utils.only_required_for_messages(
Expand Down
14 changes: 14 additions & 0 deletions pylint/config/config_initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from __future__ import annotations

import sys
import warnings
from glob import glob
from itertools import chain
from pathlib import Path
Expand Down Expand Up @@ -102,6 +103,19 @@ def _config_initialization(
"unrecognized-option", args=unrecognized_options_message, line=0
)

# TODO 3.1: Change this to emit unknown-option-value
Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas May 19, 2023

Choose a reason for hiding this comment

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

I think this need to be removed from pylint and moved to the config upgrader. Doing those kind of checks at runtime is costly and unnecessary.

for exc_name in linter.config.overgeneral_exceptions:
if "." not in exc_name:
warnings.warn_explicit(
f"'{exc_name}' is not a proper value for the 'overgeneral-exceptions' option. "
f"Use fully qualified name (maybe 'builtins.{exc_name}' ?) instead. "
"This will cease to be checked at runtime in 3.1.0.",
category=UserWarning,
filename="pylint: Command line or configuration file",
lineno=1,
module="pylint",
)

linter._emit_stashed_messages()

# Set the current module to configuration as we don't know where
Expand Down