From 00ad109a39487c18bc02926dc78051fd3938a485 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Fri, 3 Jan 2025 01:09:26 +0000 Subject: [PATCH] Run Ruff on ``tests/roots/`` --- .ruff.toml | 10 +++- .../enumerable_node.py | 12 ++-- .../conf.py | 2 +- .../mypackage/mymodule.py | 0 .../test-apidoc-pep420/a/b/c/__init__.py | 2 +- tests/roots/test-apidoc-pep420/a/b/c/d.py | 2 +- tests/roots/test-apidoc-pep420/a/b/e/f.py | 2 +- tests/roots/test-apidoc-pep420/a/b/x/y.py | 2 +- .../parent/child/foo.py | 2 +- tests/roots/test-apidoc-toc/mypackage/main.py | 6 +- .../mypackage/something/__init__.py | 2 +- .../package_/__init__.py | 2 +- .../package_/module_.py | 6 +- tests/roots/test-autosummary/dummy_module.py | 22 ++++---- .../test-autosummary/underscore_module_.py | 7 ++- tests/roots/test-basic/conf.py | 8 ++- tests/roots/test-build-text/conf.py | 2 +- tests/roots/test-directive-code/emphasize.rst | 3 +- tests/roots/test-directive-code/target.py | 7 ++- .../conf.py | 2 +- tests/roots/test-domain-c-intersphinx/conf.py | 2 +- .../conf.py | 2 +- .../roots/test-domain-cpp-intersphinx/conf.py | 2 +- tests/roots/test-epub-anchor-id/conf.py | 2 +- .../test-ext-autodoc/autodoc_dummy_bar.py | 1 + .../test-ext-autodoc/autodoc_dummy_module.py | 4 +- .../bug2437/autodoc_dummy_foo.py | 1 + tests/roots/test-ext-autodoc/conf.py | 2 +- .../test-ext-autodoc/target/TYPE_CHECKING.py | 2 +- .../roots/test-ext-autodoc/target/__init__.py | 35 +++++++----- .../target/_functions_to_import.py | 2 +- .../test-ext-autodoc/target/annotated.py | 4 +- .../target/autoclass_content.py | 7 +++ .../target/autodoc_type_aliases.py | 10 ++-- .../roots/test-ext-autodoc/target/classes.py | 13 +++-- .../test-ext-autodoc/target/coroutine.py | 5 +- .../test-ext-autodoc/target/decorator.py | 3 + .../test-ext-autodoc/target/descriptor.py | 5 +- .../target/docstring_signature.py | 10 ++-- .../test-ext-autodoc/target/empty_all.py | 1 + .../test-ext-autodoc/target/functions.py | 6 +- .../test-ext-autodoc/target/generic_class.py | 1 + .../test-ext-autodoc/target/genericalias.py | 1 + .../test-ext-autodoc/target/inheritance.py | 4 +- .../target/inherited_annotations.py | 8 ++- .../target/name_conflict/__init__.py | 1 + .../test-ext-autodoc/target/need_mocks.py | 7 ++- .../roots/test-ext-autodoc/target/overload.py | 36 ++++-------- .../target/partialfunction.py | 2 +- .../target/preserve_defaults.py | 56 ++++++++++++------- .../preserve_defaults_special_constructs.py | 8 ++- .../roots/test-ext-autodoc/target/private.py | 1 + .../test-ext-autodoc/target/singledispatch.py | 1 - tests/roots/test-ext-autodoc/target/slots.py | 10 ++-- .../test-ext-autodoc/target/typed_vars.py | 9 ++- .../test-ext-autodoc/target/typehints.py | 36 ++++++------ .../roots/test-ext-autodoc/target/typevar.py | 18 +++--- .../target/wrappedfunction.py | 6 +- .../autosummary_dummy_module.py | 2 +- .../test-ext-autosummary-filename-map/conf.py | 4 +- .../spam/eggs.py | 1 + .../autosummary_dummy_module.py | 1 + .../test-ext-autosummary-mock_imports/foo.py | 1 + .../autosummary_dummy_package_all/__init__.py | 2 +- .../package/module.py | 2 +- .../package/package/module.py | 2 +- .../package2/module.py | 2 +- .../test-ext-autosummary-skip-member/conf.py | 1 + .../autosummary_class_module.py | 2 +- .../autosummary_dummy_inherited_module.py | 5 +- .../autosummary_dummy_module.py | 18 +++--- .../grog/coverage_missing.py | 1 + tests/roots/test-ext-doctest-skipif/conf.py | 10 ++-- tests/roots/test-ext-doctest/conf.py | 2 +- tests/roots/test-ext-graphviz/conf.py | 2 +- .../mocksvgconverter.py | 4 +- .../test-ext-inheritance_diagram/test.py | 2 +- tests/roots/test-ext-math-compat/conf.py | 2 +- .../roots/test-ext-napoleon-paramtype/conf.py | 2 +- .../test-ext-napoleon-paramtype/pkg/bar.py | 2 +- .../test-ext-napoleon-paramtype/pkg/foo.py | 1 + .../not_a_package/submodule.py | 4 +- tests/roots/test-ext-viewcode/conf.py | 14 ++--- tests/roots/test-ext-viewcode/spam/mod1.py | 1 + tests/roots/test-extensions/read_parallel.py | 2 +- tests/roots/test-extensions/read_serial.py | 2 +- tests/roots/test-extensions/write_serial.py | 2 +- tests/roots/test-highlight_options/conf.py | 2 +- tests/roots/test-html_assets/conf.py | 20 +++++-- .../test-image-in-parsed-literal/conf.py | 4 +- tests/roots/test-image-in-section/conf.py | 4 +- tests/roots/test-inheritance/dummy/test.py | 2 +- .../test-inheritance/dummy/test_nested.py | 5 +- tests/roots/test-intl/conf.py | 2 +- .../roots/test-latex-includegraphics/conf.py | 4 +- .../automodule1.py | 1 - .../automodule2a.py | 1 - .../automodule2b.py | 1 - .../automodule3.py | 1 - tests/roots/test-latex-numfig/conf.py | 6 +- tests/roots/test-latex-title/conf.py | 2 +- tests/roots/test-local-logo/conf.py | 10 +++- tests/roots/test-markup-citation/conf.py | 8 ++- tests/roots/test-markup-rubric/conf.py | 8 ++- tests/roots/test-remote-logo/conf.py | 12 +++- tests/roots/test-roles-download/conf.py | 8 ++- tests/roots/test-root/autodoc_target.py | 32 ++++++----- tests/roots/test-root/conf.py | 36 ++++++++---- tests/roots/test-root/special/code.py | 4 +- tests/roots/test-stylesheets/conf.py | 6 +- tests/roots/test-templating/conf.py | 2 +- .../test-util-copyasset_overwrite/myext.py | 6 +- tests/roots/test-versioning/conf.py | 2 +- tests/test_directives/test_directive_code.py | 2 +- .../test_ext_autodoc_configs.py | 9 +-- 115 files changed, 423 insertions(+), 298 deletions(-) mode change 100755 => 100644 tests/roots/test-apidoc-custom-templates/mypackage/mymodule.py diff --git a/.ruff.toml b/.ruff.toml index 7061869712f..ce194986213 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -3,9 +3,10 @@ line-length = 88 output-format = "full" extend-exclude = [ - "tests/roots/*", "build/*", "doc/_build/*", + "tests/roots/test-directive-code/target.py", # Tests break if formatted + "tests/roots/test-pycode/cp_1251_coded.py", # Not UTF-8 ] [format] @@ -338,8 +339,15 @@ select = [ # test roots are not packages "tests/js/roots/*" = ["I002", "INP001"] +"tests/roots/*" = [ + "D403", # permit uncapitalised docstrings + "F401", # names may be unused in test roots + "I002", # we don't need the annotations future + "INP001", # test roots are not packages +] # these tests need old ``typing`` generic aliases +"tests/roots/test-ext-autodoc/target/genericalias.py" = ["UP006", "UP007", "UP035"] "tests/test_util/test_util_typing.py" = ["RUF036", "UP006", "UP007", "UP035"] "tests/test_util/typing_test_data.py" = ["FA100", "I002", "PYI030", "UP006", "UP007", "UP035"] diff --git a/tests/roots/test-add_enumerable_node/enumerable_node.py b/tests/roots/test-add_enumerable_node/enumerable_node.py index 782365e655b..2cf93e9104f 100644 --- a/tests/roots/test-add_enumerable_node/enumerable_node.py +++ b/tests/roots/test-add_enumerable_node/enumerable_node.py @@ -37,7 +37,7 @@ def visit_numbered_text(self, node): raise nodes.SkipNode -def get_title(node): +def get_title(node): # NoQA: FURB118 return node['title'] @@ -51,12 +51,14 @@ def run(self): def setup(app): # my-figure - app.add_enumerable_node(my_figure, 'figure', - html=(visit_my_figure, depart_my_figure)) + app.add_enumerable_node( + my_figure, 'figure', html=(visit_my_figure, depart_my_figure) + ) app.add_directive('my-figure', MyFigure) # numbered_label - app.add_enumerable_node(numbered_text, 'original', get_title, - html=(visit_numbered_text, None)) + app.add_enumerable_node( + numbered_text, 'original', get_title, html=(visit_numbered_text, None) + ) app.add_directive('numbered-text', NumberedText) app.config.numfig_format.setdefault('original', 'No.%s') diff --git a/tests/roots/test-add_source_parser-conflicts-with-users-setting/conf.py b/tests/roots/test-add_source_parser-conflicts-with-users-setting/conf.py index 5f979c70918..25d1e76be4d 100644 --- a/tests/roots/test-add_source_parser-conflicts-with-users-setting/conf.py +++ b/tests/roots/test-add_source_parser-conflicts-with-users-setting/conf.py @@ -16,5 +16,5 @@ class DummyTestParser(Parser): '.test': 'restructuredtext', } source_parsers = { - '.test': DummyTestParser + '.test': DummyTestParser, } diff --git a/tests/roots/test-apidoc-custom-templates/mypackage/mymodule.py b/tests/roots/test-apidoc-custom-templates/mypackage/mymodule.py old mode 100755 new mode 100644 diff --git a/tests/roots/test-apidoc-pep420/a/b/c/__init__.py b/tests/roots/test-apidoc-pep420/a/b/c/__init__.py index 5b727c1139b..0dda7cf32df 100644 --- a/tests/roots/test-apidoc-pep420/a/b/c/__init__.py +++ b/tests/roots/test-apidoc-pep420/a/b/c/__init__.py @@ -1 +1 @@ -"Package C" +"""Package C""" diff --git a/tests/roots/test-apidoc-pep420/a/b/c/d.py b/tests/roots/test-apidoc-pep420/a/b/c/d.py index 63b0e3436b8..7566ec33bc2 100644 --- a/tests/roots/test-apidoc-pep420/a/b/c/d.py +++ b/tests/roots/test-apidoc-pep420/a/b/c/d.py @@ -1 +1 @@ -"Module d" +"""Module d""" diff --git a/tests/roots/test-apidoc-pep420/a/b/e/f.py b/tests/roots/test-apidoc-pep420/a/b/e/f.py index a09affe861f..1a33f3970b4 100644 --- a/tests/roots/test-apidoc-pep420/a/b/e/f.py +++ b/tests/roots/test-apidoc-pep420/a/b/e/f.py @@ -1 +1 @@ -"Module f" +"""Module f""" diff --git a/tests/roots/test-apidoc-pep420/a/b/x/y.py b/tests/roots/test-apidoc-pep420/a/b/x/y.py index 46bc245051b..14beabd289b 100644 --- a/tests/roots/test-apidoc-pep420/a/b/x/y.py +++ b/tests/roots/test-apidoc-pep420/a/b/x/y.py @@ -1 +1 @@ -"Module y" +"""Module y""" diff --git a/tests/roots/test-apidoc-subpackage-in-toc/parent/child/foo.py b/tests/roots/test-apidoc-subpackage-in-toc/parent/child/foo.py index 810c96eeeb7..6d3c1bc67e3 100644 --- a/tests/roots/test-apidoc-subpackage-in-toc/parent/child/foo.py +++ b/tests/roots/test-apidoc-subpackage-in-toc/parent/child/foo.py @@ -1 +1 @@ -"foo" +"""foo""" diff --git a/tests/roots/test-apidoc-toc/mypackage/main.py b/tests/roots/test-apidoc-toc/mypackage/main.py index 1f6d1376cbb..c016eb4d702 100755 --- a/tests/roots/test-apidoc-toc/mypackage/main.py +++ b/tests/roots/test-apidoc-toc/mypackage/main.py @@ -5,9 +5,9 @@ import mod_resource import mod_something -if __name__ == "__main__": - print(f"Hello, world! -> something returns: {mod_something.something()}") +if __name__ == '__main__': + print(f'Hello, world! -> something returns: {mod_something.something()}') res_path = Path(mod_resource.__file__).parent / 'resource.txt' text = res_path.read_text(encoding='utf-8') - print(f"From mod_resource:resource.txt -> {text}") + print(f'From mod_resource:resource.txt -> {text}') diff --git a/tests/roots/test-apidoc-toc/mypackage/something/__init__.py b/tests/roots/test-apidoc-toc/mypackage/something/__init__.py index 6401e43ec46..a8cbeecd923 100644 --- a/tests/roots/test-apidoc-toc/mypackage/something/__init__.py +++ b/tests/roots/test-apidoc-toc/mypackage/something/__init__.py @@ -1 +1 @@ -"Subpackage Something" +"""Subpackage Something""" diff --git a/tests/roots/test-apidoc-trailing-underscore/package_/__init__.py b/tests/roots/test-apidoc-trailing-underscore/package_/__init__.py index b09612b8326..ce09465758b 100644 --- a/tests/roots/test-apidoc-trailing-underscore/package_/__init__.py +++ b/tests/roots/test-apidoc-trailing-underscore/package_/__init__.py @@ -1 +1 @@ -""" A package with trailing underscores """ +"""A package with trailing underscores""" diff --git a/tests/roots/test-apidoc-trailing-underscore/package_/module_.py b/tests/roots/test-apidoc-trailing-underscore/package_/module_.py index e16461c21ca..25d311ca4cf 100644 --- a/tests/roots/test-apidoc-trailing-underscore/package_/module_.py +++ b/tests/roots/test-apidoc-trailing-underscore/package_/module_.py @@ -1,9 +1,9 @@ -""" A module with a trailing underscore """ +"""A module with a trailing underscore""" class SomeClass_: - """ A class with a trailing underscore """ + """A class with a trailing underscore""" def some_function_(some_arg_): - """ A function with a trailing underscore in name and argument """ + """A function with a trailing underscore in name and argument""" diff --git a/tests/roots/test-autosummary/dummy_module.py b/tests/roots/test-autosummary/dummy_module.py index e552fa2dbfb..ac261c62805 100644 --- a/tests/roots/test-autosummary/dummy_module.py +++ b/tests/roots/test-autosummary/dummy_module.py @@ -11,26 +11,26 @@ def with_sentence(): - '''I have a sentence which + """I have a sentence which spans multiple lines. Then I have more stuff - ''' + """ pass def no_sentence(): - '''this doesn't start with a + """this doesn't start with a capital. so it's not considered a sentence - ''' + """ pass def empty_line(): - '''This is the real summary + """This is the real summary However, it did't end with a period. - ''' + """ pass @@ -41,11 +41,11 @@ def empty_line(): class C: - ''' + """ My C class with class_attr attribute - ''' + """ #: This is a class attribute #: @@ -56,7 +56,7 @@ def __init__(self): #: This is an instance attribute #: #: value is a string - self.instance_attr = "42" + self.instance_attr = '42' def _prop_attr_get(self): """ @@ -76,9 +76,9 @@ def _prop_attr_get(self): """ class C2: - ''' + """ This is a nested inner class docstring - ''' + """ def func(arg_, *args, **kwargs): diff --git a/tests/roots/test-autosummary/underscore_module_.py b/tests/roots/test-autosummary/underscore_module_.py index 8584e60787b..9ef28259075 100644 --- a/tests/roots/test-autosummary/underscore_module_.py +++ b/tests/roots/test-autosummary/underscore_module_.py @@ -4,12 +4,13 @@ class class_: - """ Class """ + """Class""" + def method_(_arg): - """ Method """ + """Method""" pass def function_(_arg): - """ Function """ + """Function""" pass diff --git a/tests/roots/test-basic/conf.py b/tests/roots/test-basic/conf.py index 69a316101c9..c4fb1abdda2 100644 --- a/tests/roots/test-basic/conf.py +++ b/tests/roots/test-basic/conf.py @@ -1,4 +1,10 @@ html_theme = 'basic' latex_documents = [ - ('index', 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report') + ( + 'index', + 'test.tex', + 'The basic Sphinx documentation for testing', + 'Sphinx', + 'report', + ) ] diff --git a/tests/roots/test-build-text/conf.py b/tests/roots/test-build-text/conf.py index b0fdaf8d231..b20b895493f 100644 --- a/tests/roots/test-build-text/conf.py +++ b/tests/roots/test-build-text/conf.py @@ -1,4 +1,4 @@ source_suffix = { - '.txt': 'restructuredtext' + '.txt': 'restructuredtext', } exclude_patterns = ['_build'] diff --git a/tests/roots/test-directive-code/emphasize.rst b/tests/roots/test-directive-code/emphasize.rst index 95db574cebe..ae444e9a89a 100644 --- a/tests/roots/test-directive-code/emphasize.rst +++ b/tests/roots/test-directive-code/emphasize.rst @@ -3,5 +3,4 @@ Literal Includes with Highlighted Lines .. literalinclude:: target.py :language: python - :emphasize-lines: 5-6, 13-15, 24- - + :emphasize-lines: 6-7, 16-19, 29- diff --git a/tests/roots/test-directive-code/target.py b/tests/roots/test-directive-code/target.py index b95dffbf9ef..31f3822ac0b 100644 --- a/tests/roots/test-directive-code/target.py +++ b/tests/roots/test-directive-code/target.py @@ -1,21 +1,26 @@ # Literally included file using Python highlighting -foo = "Including Unicode characters: üöä" +foo = 'Including Unicode characters: üöä' + class Foo: pass + class Bar: def baz(): pass + # comment after Bar class definition def bar(): pass + def block_start_with_comment(): # Comment return 1 + def block_start_with_blank(): return 1 diff --git a/tests/roots/test-domain-c-c_maximum_signature_line_length/conf.py b/tests/roots/test-domain-c-c_maximum_signature_line_length/conf.py index ba480ed2884..817983754b6 100644 --- a/tests/roots/test-domain-c-c_maximum_signature_line_length/conf.py +++ b/tests/roots/test-domain-c-c_maximum_signature_line_length/conf.py @@ -1 +1 @@ -c_maximum_signature_line_length = len("str hello(str name)") - 1 +c_maximum_signature_line_length = len('str hello(str name)') - 1 diff --git a/tests/roots/test-domain-c-intersphinx/conf.py b/tests/roots/test-domain-c-intersphinx/conf.py index c176af77528..896cad799b9 100644 --- a/tests/roots/test-domain-c-intersphinx/conf.py +++ b/tests/roots/test-domain-c-intersphinx/conf.py @@ -1,4 +1,4 @@ exclude_patterns = ['_build'] extensions = [ - 'sphinx.ext.intersphinx', + 'sphinx.ext.intersphinx', ] diff --git a/tests/roots/test-domain-cpp-cpp_maximum_signature_line_length/conf.py b/tests/roots/test-domain-cpp-cpp_maximum_signature_line_length/conf.py index 1eb3a64bfc4..b75c1418f1a 100644 --- a/tests/roots/test-domain-cpp-cpp_maximum_signature_line_length/conf.py +++ b/tests/roots/test-domain-cpp-cpp_maximum_signature_line_length/conf.py @@ -1 +1 @@ -cpp_maximum_signature_line_length = len("str hello(str name)") - 1 +cpp_maximum_signature_line_length = len('str hello(str name)') - 1 diff --git a/tests/roots/test-domain-cpp-intersphinx/conf.py b/tests/roots/test-domain-cpp-intersphinx/conf.py index c176af77528..896cad799b9 100644 --- a/tests/roots/test-domain-cpp-intersphinx/conf.py +++ b/tests/roots/test-domain-cpp-intersphinx/conf.py @@ -1,4 +1,4 @@ exclude_patterns = ['_build'] extensions = [ - 'sphinx.ext.intersphinx', + 'sphinx.ext.intersphinx', ] diff --git a/tests/roots/test-epub-anchor-id/conf.py b/tests/roots/test-epub-anchor-id/conf.py index 2a56f1f6689..eb614a04051 100644 --- a/tests/roots/test-epub-anchor-id/conf.py +++ b/tests/roots/test-epub-anchor-id/conf.py @@ -1,2 +1,2 @@ def setup(app): - app.add_crossref_type(directivename="setting", rolename="setting") + app.add_crossref_type(directivename='setting', rolename='setting') diff --git a/tests/roots/test-ext-autodoc/autodoc_dummy_bar.py b/tests/roots/test-ext-autodoc/autodoc_dummy_bar.py index 3b5bbfdd1cb..c66a33741d9 100644 --- a/tests/roots/test-ext-autodoc/autodoc_dummy_bar.py +++ b/tests/roots/test-ext-autodoc/autodoc_dummy_bar.py @@ -3,4 +3,5 @@ class Bar: """Dummy class Bar with alias.""" + my_name = Foo diff --git a/tests/roots/test-ext-autodoc/autodoc_dummy_module.py b/tests/roots/test-ext-autodoc/autodoc_dummy_module.py index c05d96e0d6d..21380310662 100644 --- a/tests/roots/test-ext-autodoc/autodoc_dummy_module.py +++ b/tests/roots/test-ext-autodoc/autodoc_dummy_module.py @@ -1,6 +1,6 @@ -from dummy import * +from dummy import * # NoQA: F403 def test(): """Dummy function using dummy.*""" - dummy_function() + dummy_function() # NoQA: F405 diff --git a/tests/roots/test-ext-autodoc/bug2437/autodoc_dummy_foo.py b/tests/roots/test-ext-autodoc/bug2437/autodoc_dummy_foo.py index 9c954d80a52..227c28f3d25 100644 --- a/tests/roots/test-ext-autodoc/bug2437/autodoc_dummy_foo.py +++ b/tests/roots/test-ext-autodoc/bug2437/autodoc_dummy_foo.py @@ -1,3 +1,4 @@ class Foo: """Dummy class Foo.""" + pass diff --git a/tests/roots/test-ext-autodoc/conf.py b/tests/roots/test-ext-autodoc/conf.py index abaea1c996b..f134359a32a 100644 --- a/tests/roots/test-ext-autodoc/conf.py +++ b/tests/roots/test-ext-autodoc/conf.py @@ -6,7 +6,7 @@ extensions = ['sphinx.ext.autodoc'] autodoc_mock_imports = [ - 'dummy' + 'dummy', ] nitpicky = True diff --git a/tests/roots/test-ext-autodoc/target/TYPE_CHECKING.py b/tests/roots/test-ext-autodoc/target/TYPE_CHECKING.py index 85aea3a090e..08068a49734 100644 --- a/tests/roots/test-ext-autodoc/target/TYPE_CHECKING.py +++ b/tests/roots/test-ext-autodoc/target/TYPE_CHECKING.py @@ -1,6 +1,6 @@ from __future__ import annotations -from gettext import NullTranslations +from gettext import NullTranslations # NoQA: TC003 from typing import TYPE_CHECKING if TYPE_CHECKING: diff --git a/tests/roots/test-ext-autodoc/target/__init__.py b/tests/roots/test-ext-autodoc/target/__init__.py index d7ee4ac0f37..8b9c445c5be 100644 --- a/tests/roots/test-ext-autodoc/target/__init__.py +++ b/tests/roots/test-ext-autodoc/target/__init__.py @@ -22,11 +22,15 @@ def f(self): def _funky_classmethod(name, b, c, d, docstring=None): - """Generates a classmethod for a class from a template by filling out - some arguments.""" + """ + Generates a classmethod for a class from a template by filling out some arguments. + """ + def template(cls, a, b, c, d=4, e=5, f=6): return a, b, c, d, e, f + from functools import partial + function = partial(template, b=b, c=c, d=d) function.__name__ = name function.__doc__ = docstring @@ -64,10 +68,11 @@ def excludemeth(self): mdocattr = StringIO() """should be documented as well - süß""" - roger = _funky_classmethod("roger", 2, 3, 4) + roger = _funky_classmethod('roger', 2, 3, 4) - moore = _funky_classmethod("moore", 9, 8, 7, - docstring="moore(a, e, f) -> happiness") + moore = _funky_classmethod( + 'moore', 9, 8, 7, docstring='moore(a, e, f) -> happiness' + ) def __init__(self, arg): self.inst_attr_inline = None #: an inline documented instance attr @@ -77,15 +82,15 @@ def __init__(self, arg): """a documented instance attribute""" self._private_inst_attr = None #: a private instance attribute - def __special1__(self): + def __special1__(self): # NoQA: PLW3201 """documented special method""" - def __special2__(self): + def __special2__(self): # NoQA: PLW3201 # undocumented special method pass -class CustomDict(dict): +class CustomDict(dict): # NoQA: FURB189 """Docstring.""" @@ -116,21 +121,21 @@ class InnerChild(Outer.Inner): class DocstringSig: def __new__(cls, *new_args, **new_kwargs): """__new__(cls, d, e=1) -> DocstringSig -First line of docstring + First line of docstring rest of docstring """ def __init__(self, *init_args, **init_kwargs): """__init__(self, a, b=1) -> None -First line of docstring + First line of docstring rest of docstring """ def meth(self): """meth(FOO, BAR=1) -> BAZ -First line of docstring + First line of docstring rest of docstring """ @@ -157,7 +162,7 @@ def prop2(self): return 456 -class StrRepr(str): +class StrRepr(str): # NoQA: FURB189,SLOT000 """docstring""" def __repr__(self): @@ -176,7 +181,7 @@ class InstAttCls: #: It can have multiple lines. ca1 = 'a' - ca2 = 'b' #: Doc comment for InstAttCls.ca2. One line only. + ca2 = 'b' #: Doc comment for InstAttCls.ca2. One line only. ca3 = 'c' """Docstring for class attribute InstAttCls.ca3.""" @@ -197,8 +202,8 @@ def __init__(self): def __iter__(self): """Iterate squares of each value.""" for i in self.values: - yield i ** 2 + yield i**2 def snafucate(self): """Makes this snafucated.""" - print("snafucated") + print('snafucated') diff --git a/tests/roots/test-ext-autodoc/target/_functions_to_import.py b/tests/roots/test-ext-autodoc/target/_functions_to_import.py index 7663e979842..5e96c9f9ff6 100644 --- a/tests/roots/test-ext-autodoc/target/_functions_to_import.py +++ b/tests/roots/test-ext-autodoc/target/_functions_to_import.py @@ -4,5 +4,5 @@ from sphinx.application import Sphinx -def function_to_be_imported(app: Optional["Sphinx"]) -> str: +def function_to_be_imported(app: Optional['Sphinx']) -> str: """docstring""" diff --git a/tests/roots/test-ext-autodoc/target/annotated.py b/tests/roots/test-ext-autodoc/target/annotated.py index 7adc3e0f152..d9cdb83b9e9 100644 --- a/tests/roots/test-ext-autodoc/target/annotated.py +++ b/tests/roots/test-ext-autodoc/target/annotated.py @@ -24,7 +24,7 @@ def validate(value: str) -> str: ValidatedString = Annotated[str, FuncValidator(validate)] -def hello(name: Annotated[str, "attribute"]) -> None: +def hello(name: Annotated[str, 'attribute']) -> None: """docstring""" pass @@ -33,7 +33,7 @@ class AnnotatedAttributes: """docstring""" #: Docstring about the ``name`` attribute. - name: Annotated[str, "attribute"] + name: Annotated[str, 'attribute'] #: Docstring about the ``max_len`` attribute. max_len: list[Annotated[str, MaxLen(10, ['word_one', 'word_two'])]] diff --git a/tests/roots/test-ext-autodoc/target/autoclass_content.py b/tests/roots/test-ext-autodoc/target/autoclass_content.py index 52b98064a14..d5900ccf237 100644 --- a/tests/roots/test-ext-autodoc/target/autoclass_content.py +++ b/tests/roots/test-ext-autodoc/target/autoclass_content.py @@ -4,30 +4,35 @@ class A: class B: """A class having __init__(no docstring), no __new__""" + def __init__(self): pass class C: """A class having __init__, no __new__""" + def __init__(self): """__init__ docstring""" class D: """A class having no __init__, __new__(no docstring)""" + def __new__(cls): pass class E: """A class having no __init__, __new__""" + def __new__(cls): """__new__ docstring""" class F: """A class having both __init__ and __new__""" + def __init__(self): """__init__ docstring""" @@ -37,11 +42,13 @@ def __new__(cls): class G(C): """A class inherits __init__ without docstring.""" + def __init__(self): pass class H(E): """A class inherits __new__ without docstring.""" + def __init__(self): pass diff --git a/tests/roots/test-ext-autodoc/target/autodoc_type_aliases.py b/tests/roots/test-ext-autodoc/target/autodoc_type_aliases.py index f2c07a0c7cc..4ba37706799 100644 --- a/tests/roots/test-ext-autodoc/target/autodoc_type_aliases.py +++ b/tests/roots/test-ext-autodoc/target/autodoc_type_aliases.py @@ -1,6 +1,6 @@ from __future__ import annotations -import io +import io # NoQA: TC003 from typing import Optional, overload myint = int @@ -12,7 +12,7 @@ variable2 = None # type: myint #: docstring -variable3: Optional[myint] +variable3: Optional[myint] # NoQA: UP007 def read(r: io.BytesIO) -> io.StringIO: @@ -25,13 +25,11 @@ def sum(x: myint, y: myint) -> myint: @overload -def mult(x: myint, y: myint) -> myint: - ... +def mult(x: myint, y: myint) -> myint: ... @overload -def mult(x: float, y: float) -> float: - ... +def mult(x: float, y: float) -> float: ... def mult(x, y): diff --git a/tests/roots/test-ext-autodoc/target/classes.py b/tests/roots/test-ext-autodoc/target/classes.py index e5cce7a69de..fd36ded9525 100644 --- a/tests/roots/test-ext-autodoc/target/classes.py +++ b/tests/roots/test-ext-autodoc/target/classes.py @@ -1,7 +1,7 @@ from __future__ import annotations from inspect import Parameter, Signature -from typing import List, Union +from typing import List, Union # NoQA: UP035 class Foo: @@ -19,15 +19,20 @@ def __new__(cls, x, y): class Qux: - __signature__ = Signature(parameters=[Parameter('foo', Parameter.POSITIONAL_OR_KEYWORD), - Parameter('bar', Parameter.POSITIONAL_OR_KEYWORD)]) + __signature__ = Signature( + parameters=[ + Parameter('foo', Parameter.POSITIONAL_OR_KEYWORD), + Parameter('bar', Parameter.POSITIONAL_OR_KEYWORD), + ] + ) def __init__(self, x, y): pass -class Quux(List[Union[int, float]]): +class Quux(List[Union[int, float]]): # NoQA: UP006,UP007 """A subclass of List[Union[int, float]]""" + pass diff --git a/tests/roots/test-ext-autodoc/target/coroutine.py b/tests/roots/test-ext-autodoc/target/coroutine.py index f977b6e77e3..d1355ed4a8e 100644 --- a/tests/roots/test-ext-autodoc/target/coroutine.py +++ b/tests/roots/test-ext-autodoc/target/coroutine.py @@ -22,8 +22,8 @@ async def do_asyncgen(self): yield -async def _other_coro_func(): - return "run" +async def _other_coro_func(): # NoQA: RUF029 + return 'run' def myawait(f): @@ -31,6 +31,7 @@ def myawait(f): def wrapper(*args, **kwargs): awaitable = f(*args, **kwargs) return asyncio.run(awaitable) + return wrapper diff --git a/tests/roots/test-ext-autodoc/target/decorator.py b/tests/roots/test-ext-autodoc/target/decorator.py index faad3fff954..444a70f6f0f 100644 --- a/tests/roots/test-ext-autodoc/target/decorator.py +++ b/tests/roots/test-ext-autodoc/target/decorator.py @@ -3,6 +3,7 @@ def deco1(func): """docstring for deco1""" + @wraps(func) def wrapper(): return func() @@ -12,11 +13,13 @@ def wrapper(): def deco2(condition, message): """docstring for deco2""" + def decorator(func): def wrapper(): return func() return wrapper + return decorator diff --git a/tests/roots/test-ext-autodoc/target/descriptor.py b/tests/roots/test-ext-autodoc/target/descriptor.py index 2857c99f9d4..2c7d7389b4e 100644 --- a/tests/roots/test-ext-autodoc/target/descriptor.py +++ b/tests/roots/test-ext-autodoc/target/descriptor.py @@ -11,7 +11,7 @@ def __get__(self, obj, type=None): def meth(self): """Function.""" - return "The Answer" + return 'The Answer' class CustomDataDescriptorMeta(type): @@ -20,11 +20,12 @@ class CustomDataDescriptorMeta(type): class CustomDataDescriptor2(CustomDataDescriptor): """Descriptor class with custom metaclass docstring.""" + __metaclass__ = CustomDataDescriptorMeta class Class: - descr = CustomDataDescriptor("Descriptor instance docstring.") + descr = CustomDataDescriptor('Descriptor instance docstring.') @property def prop(self): diff --git a/tests/roots/test-ext-autodoc/target/docstring_signature.py b/tests/roots/test-ext-autodoc/target/docstring_signature.py index 981d936cd13..a6c5aa504c5 100644 --- a/tests/roots/test-ext-autodoc/target/docstring_signature.py +++ b/tests/roots/test-ext-autodoc/target/docstring_signature.py @@ -4,12 +4,14 @@ class A: class B: """B(foo, bar)""" + def __init__(self): """B(foo, bar, baz)""" class C: """C(foo, bar)""" + def __new__(cls): """C(foo, bar, baz)""" @@ -21,13 +23,13 @@ def __init__(self): class E: def __init__(self): - """E(foo: int, bar: int, baz: int) -> None \\ - E(foo: str, bar: str, baz: str) -> None \\ - E(foo: float, bar: float, baz: float)""" + r"""E(foo: int, bar: int, baz: int) -> None \ + E(foo: str, bar: str, baz: str) -> None \ + E(foo: float, bar: float, baz: float)""" # NoQA: D209 class F: def __init__(self): """F(foo: int, bar: int, baz: int) -> None F(foo: str, bar: str, baz: str) -> None - F(foo: float, bar: float, baz: float)""" + F(foo: float, bar: float, baz: float)""" # NoQA: D209 diff --git a/tests/roots/test-ext-autodoc/target/empty_all.py b/tests/roots/test-ext-autodoc/target/empty_all.py index c094cff70fe..b01855aceaa 100644 --- a/tests/roots/test-ext-autodoc/target/empty_all.py +++ b/tests/roots/test-ext-autodoc/target/empty_all.py @@ -1,6 +1,7 @@ """ docsting of empty_all module. """ + __all__ = [] diff --git a/tests/roots/test-ext-autodoc/target/functions.py b/tests/roots/test-ext-autodoc/target/functions.py index 0265fb34612..54c8803a745 100644 --- a/tests/roots/test-ext-autodoc/target/functions.py +++ b/tests/roots/test-ext-autodoc/target/functions.py @@ -9,14 +9,16 @@ async def coroutinefunc(): pass -async def asyncgenerator(): +async def asyncgenerator(): # NoQA: RUF029 yield + partial_func = partial(func) partial_coroutinefunc = partial(coroutinefunc) builtin_func = print partial_builtin_func = partial(print) -def slice_arg_func(arg: 'float64[:, :]'): + +def slice_arg_func(arg: 'float64[:, :]'): # NoQA: F821 pass diff --git a/tests/roots/test-ext-autodoc/target/generic_class.py b/tests/roots/test-ext-autodoc/target/generic_class.py index 1ec80584db3..957681ae485 100644 --- a/tests/roots/test-ext-autodoc/target/generic_class.py +++ b/tests/roots/test-ext-autodoc/target/generic_class.py @@ -9,5 +9,6 @@ # __init__ signature. class A(Generic[T]): """docstring for A""" + def __init__(self, a, b=None): pass diff --git a/tests/roots/test-ext-autodoc/target/genericalias.py b/tests/roots/test-ext-autodoc/target/genericalias.py index 06026fbbc12..fee22881b26 100644 --- a/tests/roots/test-ext-autodoc/target/genericalias.py +++ b/tests/roots/test-ext-autodoc/target/genericalias.py @@ -12,5 +12,6 @@ class Class: #: A list of int T = List[int] + #: A list of Class L = List[Class] diff --git a/tests/roots/test-ext-autodoc/target/inheritance.py b/tests/roots/test-ext-autodoc/target/inheritance.py index e06f7a842b2..5c65aa65afd 100644 --- a/tests/roots/test-ext-autodoc/target/inheritance.py +++ b/tests/roots/test-ext-autodoc/target/inheritance.py @@ -10,7 +10,7 @@ def inheritedclassmeth(cls): """Inherited class method.""" @staticmethod - def inheritedstaticmeth(cls): + def inheritedstaticmeth(cls): # NoQA: PLW0211 """Inherited static method.""" @@ -20,6 +20,6 @@ def inheritedmeth(self): pass -class MyList(list): +class MyList(list): # NoQA: FURB189 def meth(self): """docstring""" diff --git a/tests/roots/test-ext-autodoc/target/inherited_annotations.py b/tests/roots/test-ext-autodoc/target/inherited_annotations.py index 3ae58a852e4..896cc1fb83d 100644 --- a/tests/roots/test-ext-autodoc/target/inherited_annotations.py +++ b/tests/roots/test-ext-autodoc/target/inherited_annotations.py @@ -1,17 +1,19 @@ """ - Test case for #11387 corner case involving inherited - members with type annotations on python 3.9 and earlier +Test case for #11387 corner case involving inherited +members with type annotations on python 3.9 and earlier """ + class HasTypeAnnotatedMember: inherit_me: int """Inherited""" + class NoTypeAnnotation(HasTypeAnnotatedMember): a = 1 """Local""" + class NoTypeAnnotation2(HasTypeAnnotatedMember): a = 1 """Local""" - diff --git a/tests/roots/test-ext-autodoc/target/name_conflict/__init__.py b/tests/roots/test-ext-autodoc/target/name_conflict/__init__.py index 0a6f4965305..6ed930c9335 100644 --- a/tests/roots/test-ext-autodoc/target/name_conflict/__init__.py +++ b/tests/roots/test-ext-autodoc/target/name_conflict/__init__.py @@ -3,4 +3,5 @@ class foo: """docstring of target.name_conflict::foo.""" + pass diff --git a/tests/roots/test-ext-autodoc/target/need_mocks.py b/tests/roots/test-ext-autodoc/target/need_mocks.py index 940fc942812..1b8af7055d6 100644 --- a/tests/roots/test-ext-autodoc/target/need_mocks.py +++ b/tests/roots/test-ext-autodoc/target/need_mocks.py @@ -2,7 +2,7 @@ import missing_package1.missing_module1 from missing_module import missing_name from missing_package2 import missing_module2 -from missing_package3.missing_module3 import missing_name +from missing_package3.missing_module3 import missing_name # NoQA: F811 import sphinx.missing_module4 from sphinx.missing_module4 import missing_name2 @@ -11,7 +11,7 @@ @missing_name(int) def decorated_function(): """decorated_function docstring""" - return None + return None # NoQA: RET501 def func(arg: missing_module.Class): @@ -28,11 +28,12 @@ class TestAutodoc: @missing_name def decorated_method(self): """TestAutodoc::decorated_method docstring""" - return None + return None # NoQA: RET501 class Inherited(missing_module.Class): """docstring""" + pass diff --git a/tests/roots/test-ext-autodoc/target/overload.py b/tests/roots/test-ext-autodoc/target/overload.py index 4bcb6ea3cad..e8826993fcf 100644 --- a/tests/roots/test-ext-autodoc/target/overload.py +++ b/tests/roots/test-ext-autodoc/target/overload.py @@ -4,18 +4,15 @@ @overload -def sum(x: int, y: int = 0) -> int: - ... +def sum(x: int, y: int = 0) -> int: ... @overload -def sum(x: float, y: float = 0.0) -> float: - ... +def sum(x: float, y: float = 0.0) -> float: ... @overload -def sum(x: str, y: str = ...) -> str: - ... +def sum(x: str, y: str = ...) -> str: ... def sum(x, y=None): @@ -27,16 +24,13 @@ class Math: """docstring""" @overload - def sum(self, x: int, y: int = 0) -> int: - ... + def sum(self, x: int, y: int = 0) -> int: ... @overload - def sum(self, x: float, y: float = 0.0) -> float: - ... + def sum(self, x: float, y: float = 0.0) -> float: ... @overload - def sum(self, x: str, y: str = ...) -> str: - ... + def sum(self, x: str, y: str = ...) -> str: ... def sum(self, x, y=None): """docstring""" @@ -47,12 +41,10 @@ class Foo: """docstring""" @overload - def __new__(cls, x: int, y: int) -> Foo: - ... + def __new__(cls, x: int, y: int) -> Foo: ... @overload - def __new__(cls, x: str, y: str) -> Foo: - ... + def __new__(cls, x: str, y: str) -> Foo: ... def __new__(cls, x, y): pass @@ -62,12 +54,10 @@ class Bar: """docstring""" @overload - def __init__(cls, x: int, y: int) -> None: - ... + def __init__(cls, x: int, y: int) -> None: ... @overload - def __init__(cls, x: str, y: str) -> None: - ... + def __init__(cls, x: str, y: str) -> None: ... def __init__(cls, x, y): pass @@ -75,12 +65,10 @@ def __init__(cls, x, y): class Meta(type): @overload - def __call__(cls, x: int, y: int) -> Any: - ... + def __call__(cls, x: int, y: int) -> Any: ... @overload - def __call__(cls, x: str, y: str) -> Any: - ... + def __call__(cls, x: str, y: str) -> Any: ... def __call__(cls, x, y): pass diff --git a/tests/roots/test-ext-autodoc/target/partialfunction.py b/tests/roots/test-ext-autodoc/target/partialfunction.py index 3be63eeee6e..30ba045ad26 100644 --- a/tests/roots/test-ext-autodoc/target/partialfunction.py +++ b/tests/roots/test-ext-autodoc/target/partialfunction.py @@ -8,5 +8,5 @@ def func1(a, b, c): func2 = partial(func1, 1) func3 = partial(func2, 2) -func3.__doc__ = "docstring of func3" +func3.__doc__ = 'docstring of func3' func4 = partial(func3, 3) diff --git a/tests/roots/test-ext-autodoc/target/preserve_defaults.py b/tests/roots/test-ext-autodoc/target/preserve_defaults.py index 86e103840d2..8985edae6a8 100644 --- a/tests/roots/test-ext-autodoc/target/preserve_defaults.py +++ b/tests/roots/test-ext-autodoc/target/preserve_defaults.py @@ -7,32 +7,48 @@ SENTINEL = object() -def foo(name: str = CONSTANT, - sentinel: Any = SENTINEL, - now: datetime = datetime.now(), - color: int = 0xFFFFFF, - *, - kwarg1, - kwarg2 = 0xFFFFFF) -> None: +def foo( + name: str = CONSTANT, + sentinel: Any = SENTINEL, + now: datetime = datetime.now(), # NoQA: B008,DTZ005 + color: int = 0xFFFFFF, + *, + kwarg1, + kwarg2=0xFFFFFF, +) -> None: """docstring""" class Class: """docstring""" - def meth(self, name: str = CONSTANT, sentinel: Any = SENTINEL, - now: datetime = datetime.now(), color: int = 0xFFFFFF, - *, kwarg1, kwarg2 = 0xFFFFFF) -> None: + def meth( + self, + name: str = CONSTANT, + sentinel: Any = SENTINEL, + now: datetime = datetime.now(), # NoQA: B008,DTZ005 + color: int = 0xFFFFFF, + *, + kwarg1, + kwarg2=0xFFFFFF, + ) -> None: """docstring""" @classmethod - def clsmeth(cls, name: str = CONSTANT, sentinel: Any = SENTINEL, - now: datetime = datetime.now(), color: int = 0xFFFFFF, - *, kwarg1, kwarg2 = 0xFFFFFF) -> None: + def clsmeth( + cls, + name: str = CONSTANT, + sentinel: Any = SENTINEL, + now: datetime = datetime.now(), # NoQA: B008,DTZ005 + color: int = 0xFFFFFF, + *, + kwarg1, + kwarg2=0xFFFFFF, + ) -> None: """docstring""" -get_sentinel = lambda custom=SENTINEL: custom +get_sentinel = lambda custom=SENTINEL: custom # NoQA: E731 """docstring""" @@ -44,17 +60,19 @@ class MultiLine: # only prop3 will not fail because it's on a single line whereas the others # will fail to parse. + # fmt: off prop1 = property( - lambda self: 1, doc="docstring") + lambda self: 1, doc='docstring') prop2 = property( - lambda self: 2, doc="docstring" + lambda self: 2, doc='docstring' ) - prop3 = property(lambda self: 3, doc="docstring") + prop3 = property(lambda self: 3, doc='docstring') prop4 = (property - (lambda self: 4, doc="docstring")) + (lambda self: 4, doc='docstring')) prop5 = property\ - (lambda self: 5, doc="docstring") + (lambda self: 5, doc='docstring') # NoQA: E211 + # fmt: on diff --git a/tests/roots/test-ext-autodoc/target/preserve_defaults_special_constructs.py b/tests/roots/test-ext-autodoc/target/preserve_defaults_special_constructs.py index 0fdb11ac874..ba397f86711 100644 --- a/tests/roots/test-ext-autodoc/target/preserve_defaults_special_constructs.py +++ b/tests/roots/test-ext-autodoc/target/preserve_defaults_special_constructs.py @@ -9,7 +9,7 @@ #: docstring -ze_lambda = lambda z=SENTINEL: None +ze_lambda = lambda z=SENTINEL: None # NoQA: E731 def foo(x, y, z=SENTINEL): @@ -19,6 +19,7 @@ def foo(x, y, z=SENTINEL): @dataclass class DataClass: """docstring""" + a: int b: object = SENTINEL c: list[int] = field(default_factory=lambda: [1, 2, 3]) @@ -27,6 +28,7 @@ class DataClass: @dataclass(init=False) class DataClassNoInit: """docstring""" + a: int b: object = SENTINEL c: list[int] = field(default_factory=lambda: [1, 2, 3]) @@ -34,6 +36,7 @@ class DataClassNoInit: class MyTypedDict(TypedDict): """docstring""" + a: int b: object c: list[int] @@ -41,10 +44,11 @@ class MyTypedDict(TypedDict): class MyNamedTuple1(NamedTuple): """docstring""" + a: int b: object = object() c: list[int] = [1, 2, 3] -class MyNamedTuple2(namedtuple('Base', ('a', 'b'), defaults=(0, SENTINEL))): +class MyNamedTuple2(namedtuple('Base', ('a', 'b'), defaults=(0, SENTINEL))): # NoQA: PYI024,SLOT002 """docstring""" diff --git a/tests/roots/test-ext-autodoc/target/private.py b/tests/roots/test-ext-autodoc/target/private.py index e46344818a7..de8a43c0b47 100644 --- a/tests/roots/test-ext-autodoc/target/private.py +++ b/tests/roots/test-ext-autodoc/target/private.py @@ -4,6 +4,7 @@ def private_function(name): :meta private: """ + def _public_function(name): """public_function is a docstring(). diff --git a/tests/roots/test-ext-autodoc/target/singledispatch.py b/tests/roots/test-ext-autodoc/target/singledispatch.py index 3dd5aaf388a..718504e5273 100644 --- a/tests/roots/test-ext-autodoc/target/singledispatch.py +++ b/tests/roots/test-ext-autodoc/target/singledispatch.py @@ -33,4 +33,3 @@ def _func_dict(arg: dict, kwarg=None): """A function for dict.""" # This function tests for specifying type through annotations pass - diff --git a/tests/roots/test-ext-autodoc/target/slots.py b/tests/roots/test-ext-autodoc/target/slots.py index 75c7a4a5227..3fa3f0798c4 100644 --- a/tests/roots/test-ext-autodoc/target/slots.py +++ b/tests/roots/test-ext-autodoc/target/slots.py @@ -7,9 +7,11 @@ class Foo: class Bar: """docstring""" - __slots__ = {'attr1': 'docstring of attr1', - 'attr2': 'docstring of attr2', - 'attr3': None} + __slots__ = { + 'attr1': 'docstring of attr1', + 'attr2': 'docstring of attr2', + 'attr3': None, + } __annotations__ = {'attr1': int} def __init__(self): @@ -19,4 +21,4 @@ def __init__(self): class Baz: """docstring""" - __slots__ = 'attr' + __slots__ = 'attr' # NoQA: PLC0205 diff --git a/tests/roots/test-ext-autodoc/target/typed_vars.py b/tests/roots/test-ext-autodoc/target/typed_vars.py index 0fe7468c84f..a87bd6accd3 100644 --- a/tests/roots/test-ext-autodoc/target/typed_vars.py +++ b/tests/roots/test-ext-autodoc/target/typed_vars.py @@ -8,8 +8,9 @@ class _Descriptor: def __init__(self, name): - self.__doc__ = f"This is {name}" - def __get__(self): + self.__doc__ = f'This is {name}' + + def __get__(self): # NoQA: PLE0302 pass @@ -18,12 +19,14 @@ class Class: attr2: int attr3 = 0 # type: int - descr4: int = _Descriptor("descr4") + descr4: int = _Descriptor('descr4') def __init__(self): + # fmt: off self.attr4: int = 0 #: attr4 self.attr5: int #: attr5 self.attr6 = 0 # type: int + # fmt: on """attr6""" diff --git a/tests/roots/test-ext-autodoc/target/typehints.py b/tests/roots/test-ext-autodoc/target/typehints.py index 90715945f14..589325cbf13 100644 --- a/tests/roots/test-ext-autodoc/target/typehints.py +++ b/tests/roots/test-ext-autodoc/target/typehints.py @@ -1,22 +1,22 @@ from __future__ import annotations import pathlib -from typing import Any, Tuple, TypeVar, Union +from typing import Any, Tuple, TypeVar, Union # NoQA: UP035 CONST1: int #: docstring CONST2: int = 1 #: docstring -CONST3: pathlib.PurePosixPath = pathlib.PurePosixPath("/a/b/c") +CONST3: pathlib.PurePosixPath = pathlib.PurePosixPath('/a/b/c') #: docstring -T = TypeVar("T", bound=pathlib.PurePosixPath) +T = TypeVar('T', bound=pathlib.PurePosixPath) def incr(a: int, b: int = 1) -> int: return a + b -def decr(a, b = 1): +def decr(a, b=1): # type: (int, int) -> int return a - b @@ -24,7 +24,7 @@ def decr(a, b = 1): class Math: CONST1: int CONST2: int = 1 - CONST3: pathlib.PurePosixPath = pathlib.PurePosixPath("/a/b/c") + CONST3: pathlib.PurePosixPath = pathlib.PurePosixPath('/a/b/c') def __init__(self, s: str, o: Any = None) -> None: pass @@ -32,7 +32,7 @@ def __init__(self, s: str, o: Any = None) -> None: def incr(self, a: int, b: int = 1) -> int: return a + b - def decr(self, a, b = 1): + def decr(self, a, b=1): # type: (int, int) -> int return a - b @@ -40,10 +40,11 @@ def nothing(self): # type: () -> None pass - def horse(self, - a, # type: str - b, # type: int - ): + def horse( + self, + a, # type: str + b, # type: int + ): # type: (...) -> None return @@ -53,7 +54,7 @@ def prop(self) -> int: @property def path(self) -> pathlib.PurePosixPath: - return pathlib.PurePosixPath("/a/b/c") + return pathlib.PurePosixPath('/a/b/c') def tuple_args(x: tuple[int, int | str]) -> tuple[int, int]: @@ -61,7 +62,7 @@ def tuple_args(x: tuple[int, int | str]) -> tuple[int, int]: class NewAnnotation: - def __new__(cls, i: int) -> NewAnnotation: + def __new__(cls, i: int) -> NewAnnotation: # NoQA: PYI034 pass @@ -85,12 +86,13 @@ def complex_func(arg1, arg2, arg3=None, *args, **kwargs): pass -def missing_attr(c, - a, # type: str - b=None # type: Optional[str] - ): +def missing_attr( + c, + a, # type: str + b=None, # type: Optional[str] +): # type: (...) -> str - return a + (b or "") + return a + (b or '') class _ClassWithDocumentedInit: diff --git a/tests/roots/test-ext-autodoc/target/typevar.py b/tests/roots/test-ext-autodoc/target/typevar.py index 1a02f3e2e76..6cc088a8219 100644 --- a/tests/roots/test-ext-autodoc/target/typevar.py +++ b/tests/roots/test-ext-autodoc/target/typevar.py @@ -4,29 +4,29 @@ from typing import NewType, TypeVar #: T1 -T1 = TypeVar("T1") +T1 = TypeVar('T1') -T2 = TypeVar("T2") # A TypeVar not having doc comment +T2 = TypeVar('T2') # A TypeVar not having doc comment #: T3 -T3 = TypeVar("T3", int, str) +T3 = TypeVar('T3', int, str) #: T4 -T4 = TypeVar("T4", covariant=True) +T4 = TypeVar('T4', covariant=True) # NoQA: PLC0105 #: T5 -T5 = TypeVar("T5", contravariant=True) +T5 = TypeVar('T5', contravariant=True) # NoQA: PLC0105 #: T6 -T6 = NewType("T6", date) +T6 = NewType('T6', date) #: T7 -T7 = TypeVar("T7", bound=int) +T7 = TypeVar('T7', bound=int) class Class: #: T1 - T1 = TypeVar("T1") + T1 = TypeVar('T1') #: T6 - T6 = NewType("T6", date) + T6 = NewType('T6', date) diff --git a/tests/roots/test-ext-autodoc/target/wrappedfunction.py b/tests/roots/test-ext-autodoc/target/wrappedfunction.py index 064d7774247..d02eeb73e32 100644 --- a/tests/roots/test-ext-autodoc/target/wrappedfunction.py +++ b/tests/roots/test-ext-autodoc/target/wrappedfunction.py @@ -2,16 +2,16 @@ from contextlib import contextmanager from functools import lru_cache -from typing import Generator +from typing import Generator # NoQA: UP035 -@lru_cache(maxsize=None) +@lru_cache(maxsize=None) # NoQA: UP033 def slow_function(message, timeout): """This function is slow.""" print(message) @contextmanager -def feeling_good(x: int, y: int) -> Generator: +def feeling_good(x: int, y: int) -> Generator: # NoQA: UP006 """You'll feel better in this context!""" yield diff --git a/tests/roots/test-ext-autosummary-filename-map/autosummary_dummy_module.py b/tests/roots/test-ext-autosummary-filename-map/autosummary_dummy_module.py index b88e33520b3..9ed0ce66877 100644 --- a/tests/roots/test-ext-autosummary-filename-map/autosummary_dummy_module.py +++ b/tests/roots/test-ext-autosummary-filename-map/autosummary_dummy_module.py @@ -5,7 +5,7 @@ class Foo: - class Bar: + class Bar: # NoQA: D106 pass def __init__(self): diff --git a/tests/roots/test-ext-autosummary-filename-map/conf.py b/tests/roots/test-ext-autosummary-filename-map/conf.py index ea64caec23d..7ef1c6fd7fb 100644 --- a/tests/roots/test-ext-autosummary-filename-map/conf.py +++ b/tests/roots/test-ext-autosummary-filename-map/conf.py @@ -6,6 +6,6 @@ extensions = ['sphinx.ext.autosummary'] autosummary_generate = True autosummary_filename_map = { - "autosummary_dummy_module": "module_mangled", - "autosummary_dummy_module.bar": "bar" + 'autosummary_dummy_module': 'module_mangled', + 'autosummary_dummy_module.bar': 'bar', } diff --git a/tests/roots/test-ext-autosummary-import_cycle/spam/eggs.py b/tests/roots/test-ext-autosummary-import_cycle/spam/eggs.py index 12122e88de8..9bef80f06a7 100644 --- a/tests/roots/test-ext-autosummary-import_cycle/spam/eggs.py +++ b/tests/roots/test-ext-autosummary-import_cycle/spam/eggs.py @@ -5,6 +5,7 @@ class Ham: """``spam.eggs.Ham`` class docstring.""" + a = 1 b = 2 c = 3 diff --git a/tests/roots/test-ext-autosummary-imported_members/autosummary_dummy_package/autosummary_dummy_module.py b/tests/roots/test-ext-autosummary-imported_members/autosummary_dummy_package/autosummary_dummy_module.py index 9c93f064e03..837a617093a 100644 --- a/tests/roots/test-ext-autosummary-imported_members/autosummary_dummy_package/autosummary_dummy_module.py +++ b/tests/roots/test-ext-autosummary-imported_members/autosummary_dummy_package/autosummary_dummy_module.py @@ -1,5 +1,6 @@ class Bar: """Bar class""" + pass diff --git a/tests/roots/test-ext-autosummary-mock_imports/foo.py b/tests/roots/test-ext-autosummary-mock_imports/foo.py index ab4460ef0af..36b8b4de5c2 100644 --- a/tests/roots/test-ext-autosummary-mock_imports/foo.py +++ b/tests/roots/test-ext-autosummary-mock_imports/foo.py @@ -3,4 +3,5 @@ class Foo(unknown.Class): """Foo class""" + pass diff --git a/tests/roots/test-ext-autosummary-module_all/autosummary_dummy_package_all/__init__.py b/tests/roots/test-ext-autosummary-module_all/autosummary_dummy_package_all/__init__.py index 82f2060fb58..e1ba34e63cf 100644 --- a/tests/roots/test-ext-autosummary-module_all/autosummary_dummy_package_all/__init__.py +++ b/tests/roots/test-ext-autosummary-module_all/autosummary_dummy_package_all/__init__.py @@ -10,4 +10,4 @@ def public_baz(): """Public Baz function""" -__all__ = ["PublicBar", "public_foo", "public_baz", "extra_dummy_module"] +__all__ = ['PublicBar', 'public_foo', 'public_baz', 'extra_dummy_module'] # NoQA: F822 diff --git a/tests/roots/test-ext-autosummary-recursive/package/module.py b/tests/roots/test-ext-autosummary-recursive/package/module.py index c76e7330246..30e6cb819e6 100644 --- a/tests/roots/test-ext-autosummary-recursive/package/module.py +++ b/tests/roots/test-ext-autosummary-recursive/package/module.py @@ -1,4 +1,4 @@ -from os import * +from os import * # NoQA: F403 class Foo: diff --git a/tests/roots/test-ext-autosummary-recursive/package/package/module.py b/tests/roots/test-ext-autosummary-recursive/package/package/module.py index c76e7330246..30e6cb819e6 100644 --- a/tests/roots/test-ext-autosummary-recursive/package/package/module.py +++ b/tests/roots/test-ext-autosummary-recursive/package/package/module.py @@ -1,4 +1,4 @@ -from os import * +from os import * # NoQA: F403 class Foo: diff --git a/tests/roots/test-ext-autosummary-recursive/package2/module.py b/tests/roots/test-ext-autosummary-recursive/package2/module.py index c76e7330246..30e6cb819e6 100644 --- a/tests/roots/test-ext-autosummary-recursive/package2/module.py +++ b/tests/roots/test-ext-autosummary-recursive/package2/module.py @@ -1,4 +1,4 @@ -from os import * +from os import * # NoQA: F403 class Foo: diff --git a/tests/roots/test-ext-autosummary-skip-member/conf.py b/tests/roots/test-ext-autosummary-skip-member/conf.py index f409bdc5c17..ff6cd3ccd00 100644 --- a/tests/roots/test-ext-autosummary-skip-member/conf.py +++ b/tests/roots/test-ext-autosummary-skip-member/conf.py @@ -13,6 +13,7 @@ def skip_member(app, what, name, obj, skip, options): return True elif name == '_privatemeth': return False + return None def setup(app): diff --git a/tests/roots/test-ext-autosummary/autosummary_class_module.py b/tests/roots/test-ext-autosummary/autosummary_class_module.py index 2b1f40419d6..050e8a09605 100644 --- a/tests/roots/test-ext-autosummary/autosummary_class_module.py +++ b/tests/roots/test-ext-autosummary/autosummary_class_module.py @@ -1,2 +1,2 @@ class Class: - pass + pass diff --git a/tests/roots/test-ext-autosummary/autosummary_dummy_inherited_module.py b/tests/roots/test-ext-autosummary/autosummary_dummy_inherited_module.py index 2b3d2da84ca..3672c13b400 100644 --- a/tests/roots/test-ext-autosummary/autosummary_dummy_inherited_module.py +++ b/tests/roots/test-ext-autosummary/autosummary_dummy_inherited_module.py @@ -2,12 +2,11 @@ class InheritedAttrClass(Foo): - def __init__(self): #: other docstring - self.subclassattr = "subclassattr" + self.subclassattr = 'subclassattr' super().__init__() -__all__ = ["InheritedAttrClass"] +__all__ = ['InheritedAttrClass'] diff --git a/tests/roots/test-ext-autosummary/autosummary_dummy_module.py b/tests/roots/test-ext-autosummary/autosummary_dummy_module.py index 2d8829a2375..c8575d3a122 100644 --- a/tests/roots/test-ext-autosummary/autosummary_dummy_module.py +++ b/tests/roots/test-ext-autosummary/autosummary_dummy_module.py @@ -4,13 +4,13 @@ from autosummary_class_module import Class __all__ = [ - "CONSTANT1", - "Exc", - "Foo", - "_Baz", - "bar", - "qux", - "path", + 'CONSTANT1', + 'Exc', + 'Foo', + '_Baz', + 'bar', + 'qux', + 'path', ] #: module variable @@ -23,7 +23,7 @@ class Foo: CONSTANT3 = None CONSTANT4 = None - class Bar: + class Bar: # NoQA: D106 pass def __init__(self): @@ -42,7 +42,7 @@ class _Baz: pass -def bar(x: Union[int, str], y: int = 1) -> None: +def bar(x: Union[int, str], y: int = 1) -> None: # NoQA: UP007 pass diff --git a/tests/roots/test-ext-coverage/grog/coverage_missing.py b/tests/roots/test-ext-coverage/grog/coverage_missing.py index 2fe44338caa..b737f0d3776 100644 --- a/tests/roots/test-ext-coverage/grog/coverage_missing.py +++ b/tests/roots/test-ext-coverage/grog/coverage_missing.py @@ -1,5 +1,6 @@ """This module is intentionally not documented.""" + class Missing: """An undocumented class.""" diff --git a/tests/roots/test-ext-doctest-skipif/conf.py b/tests/roots/test-ext-doctest-skipif/conf.py index ae00e35407f..fc999b43494 100644 --- a/tests/roots/test-ext-doctest-skipif/conf.py +++ b/tests/roots/test-ext-doctest-skipif/conf.py @@ -3,16 +3,16 @@ project = 'test project for the doctest :skipif: directive' root_doc = 'skipif' source_suffix = { - '.txt': 'restructuredtext' + '.txt': 'restructuredtext', } exclude_patterns = ['_build'] -doctest_global_setup = ''' +doctest_global_setup = """ from tests.test_extensions.test_ext_doctest import record record('doctest_global_setup', 'body', True) -''' +""" -doctest_global_cleanup = ''' +doctest_global_cleanup = """ record('doctest_global_cleanup', 'body', True) -''' +""" diff --git a/tests/roots/test-ext-doctest/conf.py b/tests/roots/test-ext-doctest/conf.py index 57fc40607b6..ce73258e5b6 100644 --- a/tests/roots/test-ext-doctest/conf.py +++ b/tests/roots/test-ext-doctest/conf.py @@ -3,6 +3,6 @@ project = 'test project for doctest' root_doc = 'doctest' source_suffix = { - '.txt': 'restructuredtext' + '.txt': 'restructuredtext', } exclude_patterns = ['_build'] diff --git a/tests/roots/test-ext-graphviz/conf.py b/tests/roots/test-ext-graphviz/conf.py index 317457ff95b..1a12f2c2b54 100644 --- a/tests/roots/test-ext-graphviz/conf.py +++ b/tests/roots/test-ext-graphviz/conf.py @@ -1,3 +1,3 @@ extensions = ['sphinx.ext.graphviz'] exclude_patterns = ['_build'] -html_static_path = ["_static"] +html_static_path = ['_static'] diff --git a/tests/roots/test-ext-imgmockconverter/mocksvgconverter.py b/tests/roots/test-ext-imgmockconverter/mocksvgconverter.py index 234732ddc0c..97b08a9a3a7 100644 --- a/tests/roots/test-ext-imgmockconverter/mocksvgconverter.py +++ b/tests/roots/test-ext-imgmockconverter/mocksvgconverter.py @@ -1,6 +1,4 @@ -""" - Does foo.svg --> foo.pdf with no change to the file. -""" +"""Does foo.svg --> foo.pdf with no change to the file.""" from __future__ import annotations diff --git a/tests/roots/test-ext-inheritance_diagram/test.py b/tests/roots/test-ext-inheritance_diagram/test.py index efb1c2a7f6e..0146c5d0f39 100644 --- a/tests/roots/test-ext-inheritance_diagram/test.py +++ b/tests/roots/test-ext-inheritance_diagram/test.py @@ -18,5 +18,5 @@ class DocMainLevel(Foo): pass -class Alice(object): +class Alice(object): # NoQA: UP004 pass diff --git a/tests/roots/test-ext-math-compat/conf.py b/tests/roots/test-ext-math-compat/conf.py index 85e3950a5d0..82cc265bc9f 100644 --- a/tests/roots/test-ext-math-compat/conf.py +++ b/tests/roots/test-ext-math-compat/conf.py @@ -4,7 +4,7 @@ extensions = ['sphinx.ext.mathjax'] -def my_math_role(role, rawtext, text, lineno, inliner, options={}, content=[]): +def my_math_role(role, rawtext, text, lineno, inliner, options={}, content=[]): # NoQA: B006 text = 'E = mc^2' return [nodes.math(text, text)], [] diff --git a/tests/roots/test-ext-napoleon-paramtype/conf.py b/tests/roots/test-ext-napoleon-paramtype/conf.py index 70d30ce0a65..1eb7bb0b5c1 100644 --- a/tests/roots/test-ext-napoleon-paramtype/conf.py +++ b/tests/roots/test-ext-napoleon-paramtype/conf.py @@ -6,7 +6,7 @@ extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.napoleon', - 'sphinx.ext.intersphinx' + 'sphinx.ext.intersphinx', ] # Python inventory is manually created in the test diff --git a/tests/roots/test-ext-napoleon-paramtype/pkg/bar.py b/tests/roots/test-ext-napoleon-paramtype/pkg/bar.py index e1ae794c799..a1560f99141 100644 --- a/tests/roots/test-ext-napoleon-paramtype/pkg/bar.py +++ b/tests/roots/test-ext-napoleon-paramtype/pkg/bar.py @@ -1,5 +1,6 @@ class Bar: """The bar.""" + def list(self) -> None: """A list method.""" @@ -7,4 +8,3 @@ def list(self) -> None: def int() -> float: """An int method.""" return 1.0 - diff --git a/tests/roots/test-ext-napoleon-paramtype/pkg/foo.py b/tests/roots/test-ext-napoleon-paramtype/pkg/foo.py index 6979f9e4a19..a6116f6d619 100644 --- a/tests/roots/test-ext-napoleon-paramtype/pkg/foo.py +++ b/tests/roots/test-ext-napoleon-paramtype/pkg/foo.py @@ -1,5 +1,6 @@ class Foo: """The foo.""" + def do( self, *, diff --git a/tests/roots/test-ext-viewcode-find/not_a_package/submodule.py b/tests/roots/test-ext-viewcode-find/not_a_package/submodule.py index ba8be78de5f..9b6d09166c1 100644 --- a/tests/roots/test-ext-viewcode-find/not_a_package/submodule.py +++ b/tests/roots/test-ext-viewcode-find/not_a_package/submodule.py @@ -1,7 +1,8 @@ """ submodule """ -raise RuntimeError('This module should not get imported') + +raise RuntimeError('This module should not get imported') # NoQA: EM101 def decorator(f): @@ -27,5 +28,6 @@ class Class3: """ this is Class3 """ + class_attr = 42 """this is the class attribute class_attr""" diff --git a/tests/roots/test-ext-viewcode/conf.py b/tests/roots/test-ext-viewcode/conf.py index 0a5d2fcb06b..5388dd15696 100644 --- a/tests/roots/test-ext-viewcode/conf.py +++ b/tests/roots/test-ext-viewcode/conf.py @@ -7,17 +7,17 @@ exclude_patterns = ['_build'] -if 'test_linkcode' in tags: +if 'test_linkcode' in tags: # NoQA: F821 (tags is injected into conf.py) extensions.remove('sphinx.ext.viewcode') extensions.append('sphinx.ext.linkcode') def linkcode_resolve(domain, info): if domain == 'py': fn = info['module'].replace('.', '/') - return "https://foobar/source/%s.py" % fn - elif domain == "js": - return "https://foobar/js/" + info['fullname'] - elif domain in ("c", "cpp"): - return f"https://foobar/{domain}/{''.join(info['names'])}" + return 'https://foobar/source/%s.py' % fn + elif domain == 'js': + return 'https://foobar/js/' + info['fullname'] + elif domain in {'c', 'cpp'}: + return f'https://foobar/{domain}/{"".join(info["names"])}' else: - raise AssertionError() + raise AssertionError diff --git a/tests/roots/test-ext-viewcode/spam/mod1.py b/tests/roots/test-ext-viewcode/spam/mod1.py index a078328c283..13f43282202 100644 --- a/tests/roots/test-ext-viewcode/spam/mod1.py +++ b/tests/roots/test-ext-viewcode/spam/mod1.py @@ -26,5 +26,6 @@ class Class3: """ this is Class3 """ + class_attr = 42 """this is the class attribute class_attr""" diff --git a/tests/roots/test-extensions/read_parallel.py b/tests/roots/test-extensions/read_parallel.py index a3e052f9570..08770105543 100644 --- a/tests/roots/test-extensions/read_parallel.py +++ b/tests/roots/test-extensions/read_parallel.py @@ -1,4 +1,4 @@ def setup(app): return { - 'parallel_read_safe': True + 'parallel_read_safe': True, } diff --git a/tests/roots/test-extensions/read_serial.py b/tests/roots/test-extensions/read_serial.py index c55570a5c44..4910d4f7faf 100644 --- a/tests/roots/test-extensions/read_serial.py +++ b/tests/roots/test-extensions/read_serial.py @@ -1,4 +1,4 @@ def setup(app): return { - 'parallel_read_safe': False + 'parallel_read_safe': False, } diff --git a/tests/roots/test-extensions/write_serial.py b/tests/roots/test-extensions/write_serial.py index 75494ce7772..6e2910870cb 100644 --- a/tests/roots/test-extensions/write_serial.py +++ b/tests/roots/test-extensions/write_serial.py @@ -1,4 +1,4 @@ def setup(app): return { - 'parallel_write_safe': False + 'parallel_write_safe': False, } diff --git a/tests/roots/test-highlight_options/conf.py b/tests/roots/test-highlight_options/conf.py index 90997d44482..a8ee7730db9 100644 --- a/tests/roots/test-highlight_options/conf.py +++ b/tests/roots/test-highlight_options/conf.py @@ -1,4 +1,4 @@ highlight_options = { 'default': {'default_option': True}, - 'python': {'python_option': True} + 'python': {'python_option': True}, } diff --git a/tests/roots/test-html_assets/conf.py b/tests/roots/test-html_assets/conf.py index 7f94bbbce73..7212d4ac687 100644 --- a/tests/roots/test-html_assets/conf.py +++ b/tests/roots/test-html_assets/conf.py @@ -3,10 +3,18 @@ html_static_path = ['static', 'subdir'] html_extra_path = ['extra', 'subdir'] -html_css_files = ['css/style.css', - ('https://example.com/custom.css', - {'title': 'title', 'media': 'print', 'priority': 400})] -html_js_files = ['js/custom.js', - ('https://example.com/script.js', - {'async': 'async', 'priority': 400})] +html_css_files = [ + 'css/style.css', + ( + 'https://example.com/custom.css', + {'title': 'title', 'media': 'print', 'priority': 400}, + ), +] +html_js_files = [ + 'js/custom.js', + ( + 'https://example.com/script.js', + {'async': 'async', 'priority': 400}, + ), +] exclude_patterns = ['**/_build', '**/.htpasswd'] diff --git a/tests/roots/test-image-in-parsed-literal/conf.py b/tests/roots/test-image-in-parsed-literal/conf.py index 5d06da63366..69ad26aa4e9 100644 --- a/tests/roots/test-image-in-parsed-literal/conf.py +++ b/tests/roots/test-image-in-parsed-literal/conf.py @@ -1,9 +1,9 @@ exclude_patterns = ['_build'] -rst_epilog = ''' +rst_epilog = """ .. |picture| image:: pic.png :height: 1cm :scale: 200% :align: middle :alt: alternative_text -''' +""" diff --git a/tests/roots/test-image-in-section/conf.py b/tests/roots/test-image-in-section/conf.py index 9cb250c1aef..08b11db4f63 100644 --- a/tests/roots/test-image-in-section/conf.py +++ b/tests/roots/test-image-in-section/conf.py @@ -1,8 +1,8 @@ exclude_patterns = ['_build'] -rst_epilog = ''' +rst_epilog = """ .. |picture| image:: pic.png :width: 15pt :height: 15pt :alt: alternative_text -''' +""" diff --git a/tests/roots/test-inheritance/dummy/test.py b/tests/roots/test-inheritance/dummy/test.py index 12fe8d900f3..75c65cd540f 100644 --- a/tests/roots/test-inheritance/dummy/test.py +++ b/tests/roots/test-inheritance/dummy/test.py @@ -8,7 +8,7 @@ / \ / \ E D F -""" +""" # NoQA: D208 class A: diff --git a/tests/roots/test-inheritance/dummy/test_nested.py b/tests/roots/test-inheritance/dummy/test_nested.py index 4b6801892ec..ccbde523d11 100644 --- a/tests/roots/test-inheritance/dummy/test_nested.py +++ b/tests/roots/test-inheritance/dummy/test_nested.py @@ -1,9 +1,8 @@ -"""Test with nested classes. -""" +"""Test with nested classes.""" class A: - class B: + class B: # NoQA: D106 pass diff --git a/tests/roots/test-intl/conf.py b/tests/roots/test-intl/conf.py index 09c47bb0637..2b49de56e7a 100644 --- a/tests/roots/test-intl/conf.py +++ b/tests/roots/test-intl/conf.py @@ -1,6 +1,6 @@ project = 'Sphinx intl ' source_suffix = { - '.txt': 'restructuredtext' + '.txt': 'restructuredtext', } keep_warnings = True templates_path = ['_templates'] diff --git a/tests/roots/test-latex-includegraphics/conf.py b/tests/roots/test-latex-includegraphics/conf.py index 65c19ab859c..86570bdfea3 100644 --- a/tests/roots/test-latex-includegraphics/conf.py +++ b/tests/roots/test-latex-includegraphics/conf.py @@ -1,7 +1,7 @@ exclude_patterns = ['_build'] latex_elements = { - 'preamble': r''' + 'preamble': r""" \makeatletter \def\dividetwolengths#1#2{\the\dimexpr \numexpr65536*\dimexpr#1\relax/\dimexpr#2\relax sp}% @@ -43,5 +43,5 @@ } \def\sphinxincludegraphics#1#{\tempincludegraphics#1} \makeatother -''', +""", } diff --git a/tests/roots/test-latex-labels-before-module/automodule1.py b/tests/roots/test-latex-labels-before-module/automodule1.py index 0545aa42705..fb1e2b64861 100644 --- a/tests/roots/test-latex-labels-before-module/automodule1.py +++ b/tests/roots/test-latex-labels-before-module/automodule1.py @@ -1,2 +1 @@ """docstring""" - diff --git a/tests/roots/test-latex-labels-before-module/automodule2a.py b/tests/roots/test-latex-labels-before-module/automodule2a.py index 0545aa42705..fb1e2b64861 100644 --- a/tests/roots/test-latex-labels-before-module/automodule2a.py +++ b/tests/roots/test-latex-labels-before-module/automodule2a.py @@ -1,2 +1 @@ """docstring""" - diff --git a/tests/roots/test-latex-labels-before-module/automodule2b.py b/tests/roots/test-latex-labels-before-module/automodule2b.py index 0545aa42705..fb1e2b64861 100644 --- a/tests/roots/test-latex-labels-before-module/automodule2b.py +++ b/tests/roots/test-latex-labels-before-module/automodule2b.py @@ -1,2 +1 @@ """docstring""" - diff --git a/tests/roots/test-latex-labels-before-module/automodule3.py b/tests/roots/test-latex-labels-before-module/automodule3.py index 0545aa42705..fb1e2b64861 100644 --- a/tests/roots/test-latex-labels-before-module/automodule3.py +++ b/tests/roots/test-latex-labels-before-module/automodule3.py @@ -1,2 +1 @@ """docstring""" - diff --git a/tests/roots/test-latex-numfig/conf.py b/tests/roots/test-latex-numfig/conf.py index 287bd1c9b6e..7d92eddc256 100644 --- a/tests/roots/test-latex-numfig/conf.py +++ b/tests/roots/test-latex-numfig/conf.py @@ -1,8 +1,6 @@ extensions = ['sphinx.ext.imgmath'] # for math_numfig latex_documents = [ - ('indexmanual', 'SphinxManual.tex', 'Test numfig manual', - 'Sphinx', 'manual'), - ('indexhowto', 'SphinxHowTo.tex', 'Test numfig howto', - 'Sphinx', 'howto'), + ('indexmanual', 'SphinxManual.tex', 'Test numfig manual', 'Sphinx', 'manual'), + ('indexhowto', 'SphinxHowTo.tex', 'Test numfig howto', 'Sphinx', 'howto'), ] diff --git a/tests/roots/test-latex-title/conf.py b/tests/roots/test-latex-title/conf.py index 64433165b73..2059c9f994d 100644 --- a/tests/roots/test-latex-title/conf.py +++ b/tests/roots/test-latex-title/conf.py @@ -1,4 +1,4 @@ # set empty string to the third column to use the first section title to document title latex_documents = [ - ('index', 'test.tex', '', 'Sphinx', 'report') + ('index', 'test.tex', '', 'Sphinx', 'report'), ] diff --git a/tests/roots/test-local-logo/conf.py b/tests/roots/test-local-logo/conf.py index 1a166c13058..580424fc77e 100644 --- a/tests/roots/test-local-logo/conf.py +++ b/tests/roots/test-local-logo/conf.py @@ -1,4 +1,10 @@ latex_documents = [ - ('index', 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report') + ( + 'index', + 'test.tex', + 'The basic Sphinx documentation for testing', + 'Sphinx', + 'report', + ) ] -html_logo = "images/img.png" +html_logo = 'images/img.png' diff --git a/tests/roots/test-markup-citation/conf.py b/tests/roots/test-markup-citation/conf.py index e274bde806b..facde90889e 100644 --- a/tests/roots/test-markup-citation/conf.py +++ b/tests/roots/test-markup-citation/conf.py @@ -1,3 +1,9 @@ latex_documents = [ - ('index', 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report') + ( + 'index', + 'test.tex', + 'The basic Sphinx documentation for testing', + 'Sphinx', + 'report', + ) ] diff --git a/tests/roots/test-markup-rubric/conf.py b/tests/roots/test-markup-rubric/conf.py index eccdbf78895..78d95a237d6 100644 --- a/tests/roots/test-markup-rubric/conf.py +++ b/tests/roots/test-markup-rubric/conf.py @@ -1,4 +1,10 @@ latex_documents = [ - ('index', 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report') + ( + 'index', + 'test.tex', + 'The basic Sphinx documentation for testing', + 'Sphinx', + 'report', + ) ] latex_toplevel_sectioning = 'section' diff --git a/tests/roots/test-remote-logo/conf.py b/tests/roots/test-remote-logo/conf.py index 07949ba91fc..b96edae1de7 100644 --- a/tests/roots/test-remote-logo/conf.py +++ b/tests/roots/test-remote-logo/conf.py @@ -1,5 +1,11 @@ latex_documents = [ - ('index', 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report') + ( + 'index', + 'test.tex', + 'The basic Sphinx documentation for testing', + 'Sphinx', + 'report', + ) ] -html_logo = "https://www.python.org/static/img/python-logo.png" -html_favicon = "https://www.python.org/static/favicon.ico" +html_logo = 'https://www.python.org/static/img/python-logo.png' +html_favicon = 'https://www.python.org/static/favicon.ico' diff --git a/tests/roots/test-roles-download/conf.py b/tests/roots/test-roles-download/conf.py index e274bde806b..facde90889e 100644 --- a/tests/roots/test-roles-download/conf.py +++ b/tests/roots/test-roles-download/conf.py @@ -1,3 +1,9 @@ latex_documents = [ - ('index', 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report') + ( + 'index', + 'test.tex', + 'The basic Sphinx documentation for testing', + 'Sphinx', + 'report', + ) ] diff --git a/tests/roots/test-root/autodoc_target.py b/tests/roots/test-root/autodoc_target.py index 59f6c74d64c..e320bddbb4f 100644 --- a/tests/roots/test-root/autodoc_target.py +++ b/tests/roots/test-root/autodoc_target.py @@ -32,7 +32,7 @@ def __get__(self, obj, type=None): def meth(self): """Function.""" - return "The Answer" + return 'The Answer' class CustomDataDescriptorMeta(type): @@ -41,15 +41,20 @@ class CustomDataDescriptorMeta(type): class CustomDataDescriptor2(CustomDataDescriptor): """Descriptor class with custom metaclass docstring.""" + __metaclass__ = CustomDataDescriptorMeta def _funky_classmethod(name, b, c, d, docstring=None): - """Generates a classmethod for a class from a template by filling out - some arguments.""" + """ + Generates a classmethod for a class from a template by filling out some arguments. + """ + def template(cls, a, b, c, d=4, e=5, f=6): return a, b, c, d, e, f + from functools import partial + function = partial(template, b=b, c=c, d=d) function.__name__ = name function.__doc__ = docstring @@ -70,7 +75,7 @@ def inheritedmeth(self): class Class(Base): """Class to document.""" - descr = CustomDataDescriptor("Descriptor instance docstring.") + descr = CustomDataDescriptor('Descriptor instance docstring.') def meth(self): """Function.""" @@ -104,10 +109,11 @@ def prop(self): mdocattr = StringIO() """should be documented as well - süß""" - roger = _funky_classmethod("roger", 2, 3, 4) + roger = _funky_classmethod('roger', 2, 3, 4) - moore = _funky_classmethod("moore", 9, 8, 7, - docstring="moore(a, e, f) -> happiness") + moore = _funky_classmethod( + 'moore', 9, 8, 7, docstring='moore(a, e, f) -> happiness' + ) def __init__(self, arg): self.inst_attr_inline = None #: an inline documented instance attr @@ -117,15 +123,15 @@ def __init__(self, arg): """a documented instance attribute""" self._private_inst_attr = None #: a private instance attribute - def __special1__(self): + def __special1__(self): # NoQA: PLW3201 """documented special method""" - def __special2__(self): + def __special2__(self): # NoQA: PLW3201 # undocumented special method pass -class CustomDict(dict): +class CustomDict(dict): # NoQA: FURB189 """Docstring.""" @@ -152,7 +158,7 @@ def meth(self): class DocstringSig: def meth(self): """meth(FOO, BAR=1) -> BAZ -First line of docstring + First line of docstring rest of docstring """ @@ -179,7 +185,7 @@ def prop2(self): return 456 -class StrRepr(str): +class StrRepr(str): # NoQA: FURB189,SLOT000 def __repr__(self): return self @@ -196,7 +202,7 @@ class InstAttCls: #: It can have multiple lines. ca1 = 'a' - ca2 = 'b' #: Doc comment for InstAttCls.ca2. One line only. + ca2 = 'b' #: Doc comment for InstAttCls.ca2. One line only. ca3 = 'c' """Docstring for class attribute InstAttCls.ca3.""" diff --git a/tests/roots/test-root/conf.py b/tests/roots/test-root/conf.py index 21ec2922e97..0a750789128 100644 --- a/tests/roots/test-root/conf.py +++ b/tests/roots/test-root/conf.py @@ -8,10 +8,12 @@ from sphinx import addnodes -extensions = ['sphinx.ext.autodoc', - 'sphinx.ext.todo', - 'sphinx.ext.coverage', - 'sphinx.ext.extlinks'] +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.todo', + 'sphinx.ext.coverage', + 'sphinx.ext.extlinks', +] jsmath_path = 'dummy.js' @@ -34,9 +36,16 @@ show_authors = True numfig = True -html_sidebars = {'**': ['localtoc.html', 'relations.html', 'sourcelink.html', - 'customsb.html', 'searchbox.html'], - 'index': ['contentssb.html', 'localtoc.html', 'globaltoc.html']} +html_sidebars = { + '**': [ + 'localtoc.html', + 'relations.html', + 'sourcelink.html', + 'customsb.html', + 'searchbox.html', + ], + 'index': ['contentssb.html', 'localtoc.html', 'globaltoc.html'], +} html_last_updated_fmt = '%b %d, %Y' html_context = {'hckey': 'hcval', 'hckey_co': 'wrong_hcval_co'} @@ -122,11 +131,13 @@ coverage_c_path = ['special/*.h'] coverage_c_regexes = {'function': r'^PyAPI_FUNC\(.*\)\s+([^_][\w_]+)'} -extlinks = {'issue': ('https://bugs.python.org/issue%s', 'issue %s'), - 'pyurl': ('https://python.org/%s', None)} +extlinks = { + 'issue': ('https://bugs.python.org/issue%s', 'issue %s'), + 'pyurl': ('https://python.org/%s', None), +} # modify tags from conf.py -tags.add('confpytag') +tags.add('confpytag') # NoQA: F821 (tags is injected into conf.py) # -- extension API @@ -149,8 +160,9 @@ def setup(app): import parsermod app.add_directive('clsdir', ClassDirective) - app.add_object_type('userdesc', 'userdescrole', '%s (userdesc)', - userdesc_parse, objname='user desc') + app.add_object_type( + 'userdesc', 'userdescrole', '%s (userdesc)', userdesc_parse, objname='user desc' + ) app.add_js_file('file://moo.js') app.add_source_suffix('.foo', 'foo') app.add_source_parser(parsermod.Parser) diff --git a/tests/roots/test-root/special/code.py b/tests/roots/test-root/special/code.py index b7934b2312c..624b494459e 100644 --- a/tests/roots/test-root/special/code.py +++ b/tests/roots/test-root/special/code.py @@ -1,2 +1,2 @@ -print("line 1") -print("line 2") +print('line 1') +print('line 2') diff --git a/tests/roots/test-stylesheets/conf.py b/tests/roots/test-stylesheets/conf.py index fa37130a5c9..d3c6f62d5e0 100644 --- a/tests/roots/test-stylesheets/conf.py +++ b/tests/roots/test-stylesheets/conf.py @@ -4,6 +4,6 @@ def setup(app): app.add_css_file('persistent.css') - app.add_css_file('default.css', title="Default") - app.add_css_file('alternate1.css', title="Alternate", rel="alternate stylesheet") - app.add_css_file('alternate2.css', rel="alternate stylesheet") + app.add_css_file('default.css', title='Default') + app.add_css_file('alternate1.css', title='Alternate', rel='alternate stylesheet') + app.add_css_file('alternate2.css', rel='alternate stylesheet') diff --git a/tests/roots/test-templating/conf.py b/tests/roots/test-templating/conf.py index 7a2baeda29e..52c2526911d 100644 --- a/tests/roots/test-templating/conf.py +++ b/tests/roots/test-templating/conf.py @@ -1,6 +1,6 @@ project = 'Sphinx templating ' source_suffix = { - '.txt': 'restructuredtext' + '.txt': 'restructuredtext', } keep_warnings = True templates_path = ['_templates'] diff --git a/tests/roots/test-util-copyasset_overwrite/myext.py b/tests/roots/test-util-copyasset_overwrite/myext.py index 5ef9e69e645..e1e6c8f89b3 100644 --- a/tests/roots/test-util-copyasset_overwrite/myext.py +++ b/tests/roots/test-util-copyasset_overwrite/myext.py @@ -6,14 +6,16 @@ def _copy_asset_overwrite_hook(app): css = app.outdir / '_static' / 'custom-styles.css' # html_static_path is copied by default - assert css.read_text(encoding='utf-8') == '/* html_static_path */\n', 'invalid default text' + css_content = css.read_text(encoding='utf-8') + assert css_content == '/* html_static_path */\n', 'invalid default text' # warning generated by here copy_asset( Path(__file__).resolve().parent.joinpath('myext_static', 'custom-styles.css'), app.outdir / '_static', ) # This demonstrates that no overwriting occurs - assert css.read_text(encoding='utf-8') == '/* html_static_path */\n', 'file overwritten!' + css_content = css.read_text(encoding='utf-8') + assert css_content == '/* html_static_path */\n', 'file overwritten!' return [] diff --git a/tests/roots/test-versioning/conf.py b/tests/roots/test-versioning/conf.py index d52d1f2746c..5520b516eee 100644 --- a/tests/roots/test-versioning/conf.py +++ b/tests/roots/test-versioning/conf.py @@ -1,5 +1,5 @@ project = 'versioning test root' source_suffix = { - '.txt': 'restructuredtext' + '.txt': 'restructuredtext', } exclude_patterns = ['_build'] diff --git a/tests/test_directives/test_directive_code.py b/tests/test_directives/test_directive_code.py index 5acebd08d60..4e6c03a6663 100644 --- a/tests/test_directives/test_directive_code.py +++ b/tests/test_directives/test_directive_code.py @@ -358,7 +358,7 @@ def test_code_block_emphasize_latex(app): .read_text(encoding='utf8') .replace('\r\n', '\n') ) - includes = '\\fvset{hllines={, 5, 6, 13, 14, 15, 24, 25, 26,}}%\n' + includes = '\\fvset{hllines={, 6, 7, 16, 17, 18, 19, 29, 30, 31,}}%\n' assert includes in latex includes = '\\end{sphinxVerbatim}\n\\sphinxresetverbatimhllines\n' assert includes in latex diff --git a/tests/test_extensions/test_ext_autodoc_configs.py b/tests/test_extensions/test_ext_autodoc_configs.py index 72f3c6dad65..47a26464b7f 100644 --- a/tests/test_extensions/test_ext_autodoc_configs.py +++ b/tests/test_extensions/test_ext_autodoc_configs.py @@ -455,8 +455,7 @@ def test_autodoc_docstring_signature(app): ' __init__(self, a, b=1) -> None', ' First line of docstring', '', - ' rest of docstring', - '', + ' rest of docstring', '', '', ' .. py:method:: DocstringSig.__new__(cls, *new_args, **new_kwargs)', @@ -466,8 +465,7 @@ def test_autodoc_docstring_signature(app): ' __new__(cls, d, e=1) -> DocstringSig', ' First line of docstring', '', - ' rest of docstring', - '', + ' rest of docstring', '', '', ' .. py:method:: DocstringSig.meth()', @@ -476,8 +474,7 @@ def test_autodoc_docstring_signature(app): ' meth(FOO, BAR=1) -> BAZ', ' First line of docstring', '', - ' rest of docstring', - '', + ' rest of docstring', '', '', ' .. py:method:: DocstringSig.meth2()',