Skip to content

Commit

Permalink
Pin colorama to lowest supported version (#6970)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielNoord authored and Pierre-Sassoulas committed Jun 18, 2022
1 parent 417e8c3 commit b05ac51
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 27 deletions.
2 changes: 2 additions & 0 deletions doc/whatsnew/2/2.14/full.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Release date: TBA

Closes #2270

* Allow suppressing ``undefined-loop-variable`` and ``undefined-variable`` without raising ``useless-suppression``.

* Fixed false positive for ``undefined-variable`` for ``__class__`` in inner methods.

Closes #4032
Expand Down
38 changes: 12 additions & 26 deletions pylint/checkers/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -1081,15 +1081,6 @@ def __init__(self, linter=None):
"""This is a queue, last in first out."""
self._postponed_evaluation_enabled = False

def open(self) -> None:
"""Called when loading the checker."""
self._is_undefined_variable_enabled = self.linter.is_message_enabled(
"undefined-variable"
)
self._is_undefined_loop_variable_enabled = self.linter.is_message_enabled(
"undefined-loop-variable"
)

def leave_for(self, node: nodes.For) -> None:
self._store_type_annotation_names(node)

Expand Down Expand Up @@ -1353,8 +1344,7 @@ def visit_name(self, node: nodes.Name) -> None:
return

self._undefined_and_used_before_checker(node, stmt)
if self._is_undefined_loop_variable_enabled:
self._loopvar_name(node)
self._loopvar_name(node)

@utils.only_required_for_messages("redefined-outer-name")
def visit_excepthandler(self, node: nodes.ExceptHandler) -> None:
Expand Down Expand Up @@ -1411,23 +1401,19 @@ def _undefined_and_used_before_checker(

# we have not found the name, if it isn't a builtin, that's an
# undefined name !
if (
self._is_undefined_variable_enabled
and not (
node.name in nodes.Module.scope_attrs
or utils.is_builtin(node.name)
or node.name in self.linter.config.additional_builtins
or (
node.name == "__class__"
and any(
i.is_method()
for i in node.node_ancestors()
if isinstance(i, nodes.FunctionDef)
)
if not (
node.name in nodes.Module.scope_attrs
or utils.is_builtin(node.name)
or node.name in self.linter.config.additional_builtins
or (
node.name == "__class__"
and any(
i.is_method()
for i in node.node_ancestors()
if isinstance(i, nodes.FunctionDef)
)
)
and not utils.node_ignores_exception(node, NameError)
):
) and not utils.node_ignores_exception(node, NameError):
self.add_message("undefined-variable", args=node.name, node=node)

def _should_node_be_skipped(
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ install_requires =
mccabe>=0.6,<0.8
tomli>=1.1.0;python_version<"3.11"
tomlkit>=0.10.1
colorama;sys_platform=="win32"
colorama>=0.4.5;sys_platform=="win32"
typing-extensions>=3.10.0;python_version<"3.10"
python_requires = >=3.7.2
Expand Down

0 comments on commit b05ac51

Please sign in to comment.