Enable the PLW0603 lint in Ruff

This commit is contained in:
Adam Turner
2024-10-19 01:50:45 +01:00
parent e83892ae55
commit 3920af4700
6 changed files with 16 additions and 23 deletions

View File

@@ -57,7 +57,6 @@ ignore = [
"PLR6201", # Use a set literal when testing for membership
"PLR6301", # Method `{method_name}` could be a function, class method, or static method
# pylint ('PLW')
"PLW0603", # Using the global statement to update `{name}` is discouraged
"PLW1514", # `{function_name}` in text mode without explicit `encoding` argument
"PLW1641", # Object does not implement `__hash__` method
"PLW2901", # Outer {outer_kind} variable `{name}` overwritten by inner {inner_kind} target

View File

@@ -35,12 +35,12 @@ def terminal_supports_colour() -> bool:
def disable_colour() -> None:
global _COLOURING_DISABLED
global _COLOURING_DISABLED # NoQA: PLW0603
_COLOURING_DISABLED = True
def enable_colour() -> None:
global _COLOURING_DISABLED
global _COLOURING_DISABLED # NoQA: PLW0603
_COLOURING_DISABLED = False

View File

@@ -758,7 +758,7 @@ def new_document(source_path: str, settings: Any = None) -> nodes.document:
caches the result of docutils' and use it on second call for instantiation.
This makes an instantiation of document nodes much faster.
"""
global __document_cache__
global __document_cache__ # NoQA: PLW0603
try:
cached_settings, reporter = __document_cache__
except NameError:

View File

@@ -15,7 +15,7 @@ cleanup_called = 0
@pytest.mark.sphinx('doctest', testroot='ext-doctest')
def test_build(app):
global cleanup_called
global cleanup_called # NoQA: PLW0603
cleanup_called = 0
app.build(force_all=True)
assert app.statuscode == 0, f'failures in doctests:\n{app.status.getvalue()}'
@@ -69,7 +69,7 @@ def test_is_allowed_version():
def cleanup_call():
global cleanup_called
global cleanup_called # NoQA: PLW0603
cleanup_called += 1
@@ -87,7 +87,7 @@ def test_skipif(app):
in ``test_build`` above, and the assertion below would fail.
"""
global recorded_calls
global recorded_calls # NoQA: PLW0603
recorded_calls = Counter()
app.build(force_all=True)
if app.statuscode != 0:

View File

@@ -62,20 +62,6 @@ class DummyDomain:
return self.data
settings = parser = None
def setup_module():
global settings, parser
with warnings.catch_warnings():
warnings.filterwarnings('ignore', category=DeprecationWarning)
# DeprecationWarning: The frontend.OptionParser class will be replaced
# by a subclass of argparse.ArgumentParser in Docutils 0.21 or later.
optparser = frontend.OptionParser(components=(rst.Parser,))
settings = optparser.get_default_values()
parser = rst.Parser()
def load_searchindex(path: Path) -> Any:
searchindex = path.read_text(encoding='utf8')
assert searchindex.startswith('Search.setIndex(')
@@ -180,6 +166,14 @@ def test_term_in_raw_directive(app):
def test_IndexBuilder():
with warnings.catch_warnings():
warnings.filterwarnings('ignore', category=DeprecationWarning)
# DeprecationWarning: The frontend.OptionParser class will be replaced
# by a subclass of argparse.ArgumentParser in Docutils 0.21 or later.
optparser = frontend.OptionParser(components=(rst.Parser,))
settings = optparser.get_default_values()
parser = rst.Parser()
domain1 = DummyDomain(
'dummy1',
[

View File

@@ -8,12 +8,12 @@ import pytest
from sphinx.testing.util import SphinxTestApp
from sphinx.versioning import add_uids, get_ratio, merge_doctrees
app = original = original_uids = None
original = original_uids = None
@pytest.fixture(scope='module', autouse=True)
def _setup_module(rootdir, sphinx_test_tempdir):
global app, original, original_uids
global original, original_uids # NoQA: PLW0603
srcdir = sphinx_test_tempdir / 'test-versioning'
if not srcdir.exists():
shutil.copytree(rootdir / 'test-versioning', srcdir)