Skip to content

Commit

Permalink
Run Ruff on tests/roots/
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Jan 3, 2025
1 parent b176c66 commit 00ad109
Show file tree
Hide file tree
Showing 115 changed files with 423 additions and 298 deletions.
10 changes: 9 additions & 1 deletion .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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"]

Expand Down
12 changes: 7 additions & 5 deletions tests/roots/test-add_enumerable_node/enumerable_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']


Expand All @@ -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')
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ class DummyTestParser(Parser):
'.test': 'restructuredtext',
}
source_parsers = {
'.test': DummyTestParser
'.test': DummyTestParser,
}
Empty file modified tests/roots/test-apidoc-custom-templates/mypackage/mymodule.py
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion tests/roots/test-apidoc-pep420/a/b/c/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"Package C"
"""Package C"""
2 changes: 1 addition & 1 deletion tests/roots/test-apidoc-pep420/a/b/c/d.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"Module d"
"""Module d"""
2 changes: 1 addition & 1 deletion tests/roots/test-apidoc-pep420/a/b/e/f.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"Module f"
"""Module f"""
2 changes: 1 addition & 1 deletion tests/roots/test-apidoc-pep420/a/b/x/y.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"Module y"
"""Module y"""
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"foo"
"""foo"""
6 changes: 3 additions & 3 deletions tests/roots/test-apidoc-toc/mypackage/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}')
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"Subpackage Something"
"""Subpackage Something"""
Original file line number Diff line number Diff line change
@@ -1 +1 @@
""" A package with trailing underscores """
"""A package with trailing underscores"""
Original file line number Diff line number Diff line change
@@ -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"""
22 changes: 11 additions & 11 deletions tests/roots/test-autosummary/dummy_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -41,11 +41,11 @@ def empty_line():


class C:
'''
"""
My C class
with class_attr attribute
'''
"""

#: This is a class attribute
#:
Expand All @@ -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):
"""
Expand All @@ -76,9 +76,9 @@ def _prop_attr_get(self):
"""

class C2:
'''
"""
This is a nested inner class docstring
'''
"""


def func(arg_, *args, **kwargs):
Expand Down
7 changes: 4 additions & 3 deletions tests/roots/test-autosummary/underscore_module_.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@


class class_:
""" Class """
"""Class"""

def method_(_arg):
""" Method """
"""Method"""
pass


def function_(_arg):
""" Function """
"""Function"""
pass
8 changes: 7 additions & 1 deletion tests/roots/test-basic/conf.py
Original file line number Diff line number Diff line change
@@ -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',
)
]
2 changes: 1 addition & 1 deletion tests/roots/test-build-text/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source_suffix = {
'.txt': 'restructuredtext'
'.txt': 'restructuredtext',
}
exclude_patterns = ['_build']
3 changes: 1 addition & 2 deletions tests/roots/test-directive-code/emphasize.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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-
7 changes: 6 additions & 1 deletion tests/roots/test-directive-code/target.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c_maximum_signature_line_length = len("str hello(str name)") - 1
c_maximum_signature_line_length = len('str hello(str name)') - 1
2 changes: 1 addition & 1 deletion tests/roots/test-domain-c-intersphinx/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exclude_patterns = ['_build']
extensions = [
'sphinx.ext.intersphinx',
'sphinx.ext.intersphinx',
]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cpp_maximum_signature_line_length = len("str hello(str name)") - 1
cpp_maximum_signature_line_length = len('str hello(str name)') - 1
2 changes: 1 addition & 1 deletion tests/roots/test-domain-cpp-intersphinx/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exclude_patterns = ['_build']
extensions = [
'sphinx.ext.intersphinx',
'sphinx.ext.intersphinx',
]
2 changes: 1 addition & 1 deletion tests/roots/test-epub-anchor-id/conf.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
def setup(app):
app.add_crossref_type(directivename="setting", rolename="setting")
app.add_crossref_type(directivename='setting', rolename='setting')
1 change: 1 addition & 0 deletions tests/roots/test-ext-autodoc/autodoc_dummy_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@

class Bar:
"""Dummy class Bar with alias."""

my_name = Foo
4 changes: 2 additions & 2 deletions tests/roots/test-ext-autodoc/autodoc_dummy_module.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dummy import *
from dummy import * # NoQA: F403


def test():
"""Dummy function using dummy.*"""
dummy_function()
dummy_function() # NoQA: F405
1 change: 1 addition & 0 deletions tests/roots/test-ext-autodoc/bug2437/autodoc_dummy_foo.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
class Foo:
"""Dummy class Foo."""

pass
2 changes: 1 addition & 1 deletion tests/roots/test-ext-autodoc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
extensions = ['sphinx.ext.autodoc']

autodoc_mock_imports = [
'dummy'
'dummy',
]

nitpicky = True
2 changes: 1 addition & 1 deletion tests/roots/test-ext-autodoc/target/TYPE_CHECKING.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Loading

0 comments on commit 00ad109

Please sign in to comment.