Skip to content

Commit ab84297

Browse files
committed
pass code through ruff
1 parent 92c0fca commit ab84297

File tree

10 files changed

+147
-147
lines changed

10 files changed

+147
-147
lines changed

integration_tests/build_django.py

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env python3
22
#
3-
"""Try to build the Django documentation.
4-
"""
3+
"""Try to build the Django documentation."""
54

65
import argparse
76
import os
@@ -10,70 +9,83 @@
109
import tempfile
1110

1211

13-
def doit(*cmd, description='', cwd=None):
14-
print(f'\n[{description}]\nrunning: {" ".join(cmd)}')
12+
def doit(*cmd, description="", cwd=None):
13+
print(f"\n[{description}]\nrunning: {' '.join(cmd)}")
1514
completed = subprocess.run(cmd, cwd=cwd)
1615
try:
1716
completed.check_returncode()
1817
except subprocess.CalledProcessError as err:
19-
raise RuntimeError(f'command failed {description}') from err
18+
raise RuntimeError(f"command failed {description}") from err
2019

2120

2221
def try_build(workdir, srcdir, django_repo):
23-
print(f'working in {workdir}')
22+
print(f"working in {workdir}")
2423
doit(
25-
'git', 'clone', '--depth', '1', django_repo, 'django',
26-
description='clone django',
24+
"git",
25+
"clone",
26+
"--depth",
27+
"1",
28+
django_repo,
29+
"django",
30+
description="clone django",
2731
cwd=workdir,
2832
)
29-
djangodir = workdir + '/django'
33+
djangodir = workdir + "/django"
3034
doit(
31-
'tox', '-e', 'docs', '--notest',
32-
description='build django docs virtualenv',
35+
"tox",
36+
"-e",
37+
"docs",
38+
"--notest",
39+
description="build django docs virtualenv",
3340
cwd=djangodir,
3441
)
3542
doit(
36-
'.tox/docs/bin/pip', 'uninstall', '-y', 'sphinxcontrib-spelling',
37-
description='uninstall packaged sphinxcontrib-spelling',
43+
".tox/docs/bin/pip",
44+
"uninstall",
45+
"-y",
46+
"sphinxcontrib-spelling",
47+
description="uninstall packaged sphinxcontrib-spelling",
3848
cwd=djangodir,
3949
)
4050
doit(
41-
'.tox/docs/bin/pip', 'install', srcdir,
42-
description='install sphinxcontrib-spelling from source',
51+
".tox/docs/bin/pip",
52+
"install",
53+
srcdir,
54+
description="install sphinxcontrib-spelling from source",
4355
cwd=djangodir,
4456
)
4557
doit(
46-
'tox', '-e', 'docs',
47-
description='build django docs',
58+
"tox",
59+
"-e",
60+
"docs",
61+
description="build django docs",
4862
cwd=djangodir,
4963
)
5064

5165

5266
def main(args=sys.argv[1:]):
5367
parser = argparse.ArgumentParser()
54-
parser.add_argument('--debug', action='store_true', default=False,
55-
help='show full tracebacks')
56-
parser.add_argument('--src', help='source directory')
57-
parser.add_argument('--django-repo',
58-
default='https://github.com/django/django.git')
68+
parser.add_argument(
69+
"--debug", action="store_true", default=False, help="show full tracebacks"
70+
)
71+
parser.add_argument("--src", help="source directory")
72+
parser.add_argument("--django-repo", default="https://github.com/django/django.git")
5973
parsed = parser.parse_args(args)
6074

6175
srcdir = parsed.src
6276
if not srcdir:
63-
srcdir = os.path.realpath(
64-
os.path.dirname(os.path.dirname(sys.argv[0]))
65-
)
77+
srcdir = os.path.realpath(os.path.dirname(os.path.dirname(sys.argv[0])))
6678

6779
try:
6880
with tempfile.TemporaryDirectory() as dirname:
6981
try_build(dirname, srcdir, parsed.django_repo)
7082
except Exception as err:
7183
if parsed.debug:
7284
raise
73-
print(f'ERROR: {err}')
85+
print(f"ERROR: {err}")
7486
return 1
7587
return 0
7688

7789

78-
if __name__ == '__main__':
90+
if __name__ == "__main__":
7991
sys.exit(main())

pyproject.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ dependencies = [
7676
]
7777
[tool.hatch.envs.test.scripts]
7878
test = "python -m pytest --cov=sphinxcontrib.spelling --cov-report term-missing --log-level DEBUG tests"
79-
lint = "ruff check sphinxcontrib integration_tests tests"
79+
lint = [
80+
"ruff check sphinxcontrib integration_tests tests",
81+
"ruff format --check sphinxcontrib integration_tests tests",
82+
]
83+
lint-fix = ["ruff format sphinxcontrib integration_tests tests"]
8084
pkglint = [
8185
"hatch build",
8286
"twine check dist/*.tar.gz dist/*.whl",
@@ -87,3 +91,6 @@ pkglint = [
8791
dependencies = ["tox"]
8892
[tool.hatch.envs.integration.scripts]
8993
django = "./integration_tests/build_django.py"
94+
95+
[tool.ruff]
96+
exclude = ["sphinxcontrib/spelling/version.py"]

sphinxcontrib/spelling/__init__.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,51 +13,51 @@
1313

1414

1515
def setup(app):
16-
version = importlib_metadata.version('sphinxcontrib-spelling')
17-
logger.info('Initializing Spelling Checker %s', version)
16+
version = importlib_metadata.version("sphinxcontrib-spelling")
17+
logger.info("Initializing Spelling Checker %s", version)
1818
app.add_builder(builder.SpellingBuilder)
1919
# Register the 'spelling' directive for setting parameters within
2020
# a document
21-
app.add_directive('spelling', directive.LegacySpellingDirective)
21+
app.add_directive("spelling", directive.LegacySpellingDirective)
2222
app.add_domain(domain.SpellingDomain)
2323
# Register an environment collector to merge data gathered by the
2424
# directive in parallel builds
2525
app.add_env_collector(asset.SpellingCollector)
2626
# Report guesses about correct spelling
27-
app.add_config_value('spelling_show_suggestions', False, 'env')
27+
app.add_config_value("spelling_show_suggestions", False, "env")
2828
# Limit the number of suggestions output
29-
app.add_config_value('spelling_suggestion_limit', 0, 'env')
29+
app.add_config_value("spelling_suggestion_limit", 0, "env")
3030
# Report the whole line that has the error
31-
app.add_config_value('spelling_show_whole_line', True, 'env')
31+
app.add_config_value("spelling_show_whole_line", True, "env")
3232
# Emit misspelling as a sphinx warning instead of info message
33-
app.add_config_value('spelling_warning', False, 'env')
33+
app.add_config_value("spelling_warning", False, "env")
3434
# Set the language for the text
35-
app.add_config_value('spelling_lang', 'en_US', 'env')
35+
app.add_config_value("spelling_lang", "en_US", "env")
3636
# Set the language for the tokenizer
37-
app.add_config_value('tokenizer_lang', 'en_US', 'env')
37+
app.add_config_value("tokenizer_lang", "en_US", "env")
3838
# Set a user-provided list of words known to be spelled properly
39-
app.add_config_value('spelling_word_list_filename', None, 'env')
39+
app.add_config_value("spelling_word_list_filename", None, "env")
4040
# Assume anything that looks like a PyPI package name is spelled properly
41-
app.add_config_value('spelling_ignore_pypi_package_names', False, 'env')
41+
app.add_config_value("spelling_ignore_pypi_package_names", False, "env")
4242
# Assume words that look like wiki page names are spelled properly
43-
app.add_config_value('spelling_ignore_wiki_words', True, 'env')
43+
app.add_config_value("spelling_ignore_wiki_words", True, "env")
4444
# Assume words that are all caps, or all caps with trailing s, are
4545
# spelled properly
46-
app.add_config_value('spelling_ignore_acronyms', True, 'env')
46+
app.add_config_value("spelling_ignore_acronyms", True, "env")
4747
# Assume words that are part of __builtins__ are spelled properly
48-
app.add_config_value('spelling_ignore_python_builtins', True, 'env')
48+
app.add_config_value("spelling_ignore_python_builtins", True, "env")
4949
# Assume words that look like the names of importable modules are
5050
# spelled properly
51-
app.add_config_value('spelling_ignore_importable_modules', True, 'env')
51+
app.add_config_value("spelling_ignore_importable_modules", True, "env")
5252
# Treat contributor names from git history as spelled correctly
53-
app.add_config_value('spelling_ignore_contributor_names', True, 'env')
53+
app.add_config_value("spelling_ignore_contributor_names", True, "env")
5454
# Add any user-defined filter classes
55-
app.add_config_value('spelling_filters', [], 'env')
55+
app.add_config_value("spelling_filters", [], "env")
5656
# Set a user-provided list of files to ignore
57-
app.add_config_value('spelling_exclude_patterns', [], 'env')
57+
app.add_config_value("spelling_exclude_patterns", [], "env")
5858
# Choose whether or not the misspelled output should be displayed
5959
# in the terminal
60-
app.add_config_value('spelling_verbose', True, 'env')
60+
app.add_config_value("spelling_verbose", True, "env")
6161
return {
6262
"parallel_read_safe": True,
6363
"parallel_write_safe": True,

sphinxcontrib/spelling/asset.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414

1515
class SpellingCollector(EnvironmentCollector):
16-
1716
def clear_doc(self, app, env, docname) -> None:
1817
with contextlib.suppress(AttributeError, KeyError):
1918
del env.spelling_document_words[docname]
@@ -24,7 +23,7 @@ def merge_other(self, app, env, docnames, other):
2423
except AttributeError:
2524
other_words = {}
2625

27-
if not hasattr(env, 'spelling_document_words'):
26+
if not hasattr(env, "spelling_document_words"):
2827
env.spelling_document_words = collections.defaultdict(list)
2928
env.spelling_document_words.update(other_words)
3029

0 commit comments

Comments
 (0)