Skip to content

Commit 850fa82

Browse files
authored
Merge pull request #155 from davidhewitt/fmt-black-ci
ci: check black formatting
2 parents 1b8a85a + 1967113 commit 850fa82

File tree

18 files changed

+167
-118
lines changed

18 files changed

+167
-118
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ on:
66
pull_request:
77

88
jobs:
9+
fmt:
10+
runs-on: "ubuntu-latest"
11+
steps:
12+
- uses: actions/checkout@v2
13+
14+
- name: Set up Python ${{ matrix.python-version }}
15+
uses: actions/setup-python@v2
16+
with:
17+
python-version: "3.x"
18+
19+
- run: pip install black
20+
21+
- run: black --check .
22+
923
build:
1024
name: ${{ matrix.python-version }} ${{ matrix.platform.os }}-${{ matrix.platform.python-architecture }}
1125
runs-on: ${{ matrix.platform.os }}

docs/conf.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
# -- Project information -----------------------------------------------------
1414

15-
project = 'setuptools-rust'
16-
copyright = '2021, The PyO3 Contributors'
17-
author = 'The PyO3 Contributors'
15+
project = "setuptools-rust"
16+
copyright = "2021, The PyO3 Contributors"
17+
author = "The PyO3 Contributors"
1818

1919

2020
# -- General configuration ---------------------------------------------------
@@ -31,28 +31,28 @@
3131
]
3232

3333
# Add any paths that contain templates here, relative to this directory.
34-
templates_path = ['_templates']
34+
templates_path = ["_templates"]
3535

3636
# List of patterns, relative to source directory, that match files and
3737
# directories to ignore when looking for source files.
3838
# This pattern also affects html_static_path and html_extra_path.
39-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
39+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
4040

4141

4242
# -- Options for HTML output -------------------------------------------------
4343

4444
# The theme to use for HTML and HTML Help pages. See the documentation for
4545
# a list of builtin themes.
4646
#
47-
html_theme = 'sphinx_rtd_theme'
47+
html_theme = "sphinx_rtd_theme"
4848

4949
# Add any paths that contain custom static files (such as style sheets) here,
5050
# relative to this directory. They are copied after the builtin static files,
5151
# so a file named "default.css" will overwrite the builtin "default.css".
52-
html_static_path = ['_static']
52+
html_static_path = ["_static"]
5353

5454
html_theme_options = {
55-
'prev_next_buttons_location': None,
55+
"prev_next_buttons_location": None,
5656
}
5757

5858
# -- Custom HTML link transformation to make documentation links relative --
@@ -62,29 +62,32 @@
6262

6363
from sphinx.transforms import SphinxTransform
6464

65-
DOCS_URL = 'https://setuptools-rust.readthedocs.io/en/latest/'
65+
DOCS_URL = "https://setuptools-rust.readthedocs.io/en/latest/"
66+
6667

6768
class RelativeDocLinks(SphinxTransform):
6869

6970
default_priority = 750
7071

7172
def apply(self):
7273
from docutils.nodes import reference, Text
74+
7375
baseref = lambda o: (
74-
isinstance(o, reference) and
75-
o.get('refuri', '').startswith(DOCS_URL))
76-
basetext = lambda o: (
77-
isinstance(o, Text) and o.startswith(DOCS_URL))
76+
isinstance(o, reference) and o.get("refuri", "").startswith(DOCS_URL)
77+
)
78+
basetext = lambda o: (isinstance(o, Text) and o.startswith(DOCS_URL))
7879
for node in self.document.traverse(baseref):
79-
target = node['refuri'].replace(DOCS_URL, "", 1)
80-
node.replace_attr('refuri', target)
80+
target = node["refuri"].replace(DOCS_URL, "", 1)
81+
node.replace_attr("refuri", target)
8182
for t in node.traverse(basetext):
8283
t1 = Text(t.replace(DOCS_URL, "", 1), t.rawsource)
8384
t.parent.replace(t, t1)
8485
return
8586

87+
8688
# end of class
8789

90+
8891
def setup(app):
8992
app.add_transform(RelativeDocLinks)
9093
return

examples/html-py-ever/setup.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@
1919
"Operating System :: MacOS :: MacOS X",
2020
],
2121
packages=["html_py_ever"],
22-
install_requires=[
23-
"beautifulsoup4",
24-
"lxml"
25-
],
22+
install_requires=["beautifulsoup4", "lxml"],
2623
rust_extensions=[RustExtension("html_py_ever.html_py_ever")],
2724
include_package_data=True,
2825
zip_safe=False,

examples/html-py-ever/test/run_all.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def rust(filename: str) -> Tuple[int, float, float]:
2121

2222
def python(filename: str, parser: str) -> Tuple[int, float, float]:
2323
start_load = perf_counter()
24-
with open(filename, encoding='utf8') as fp:
24+
with open(filename, encoding="utf8") as fp:
2525
soup = BeautifulSoup(fp, parser)
2626

2727
end_load = perf_counter()

examples/html-py-ever/test/test_parsing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def rust(filename: str) -> Document:
1616

1717

1818
def python(filename: str) -> BeautifulSoup:
19-
with open(filename, encoding='utf8') as fp:
19+
with open(filename, encoding="utf8") as fp:
2020
soup = BeautifulSoup(fp, "html.parser")
2121

2222
return soup

examples/html-py-ever/test/test_selector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ def test_bench_selector_rust(benchmark, filename):
1818

1919
@pytest.mark.parametrize("filename", HTML_FILES)
2020
def test_bench_selector_python(benchmark, filename):
21-
with open(filename, encoding='utf8') as fp:
21+
with open(filename, encoding="utf8") as fp:
2222
soup = BeautifulSoup(fp, "html.parser")
2323
benchmark(soup.select, "a[href]")

examples/namespace_package/setup.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@
33

44

55
setup(
6-
name='namespace_package',
6+
name="namespace_package",
77
version="0.1.0",
8-
packages=find_namespace_packages(include=['namespace_package.*']),
8+
packages=find_namespace_packages(include=["namespace_package.*"]),
99
zip_safe=False,
10-
rust_extensions=[RustExtension("namespace_package.rust", path="Cargo.toml", binding=Binding.PyO3, debug=False)],
10+
rust_extensions=[
11+
RustExtension(
12+
"namespace_package.rust",
13+
path="Cargo.toml",
14+
binding=Binding.PyO3,
15+
debug=False,
16+
)
17+
],
1118
)

examples/namespace_package/tests/test_namespace_package.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33

44
def test_rust():
5-
assert rust.rust_func() == 14
5+
assert rust.rust_func() == 14
66

77

88
def test_cffi():
9-
assert python.python_func() == 15
9+
assert python.python_func() == 15

examples/rust_with_cffi/cffi_module.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22

33

44
ffi = cffi.FFI()
5-
ffi.cdef("""
5+
ffi.cdef(
6+
"""
67
int cffi_func(void);
7-
""")
8-
ffi.set_source("rust_with_cffi.cffi", """
8+
"""
9+
)
10+
ffi.set_source(
11+
"rust_with_cffi.cffi",
12+
"""
913
int cffi_func(void) {
1014
return 15;
1115
}
12-
""")
16+
""",
17+
)

examples/rust_with_cffi/tests/test_rust_with_cffi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44

55
def test_rust():
6-
assert rust.rust_func() == 14
6+
assert rust.rust_func() == 14
77

88

99
def test_cffi():
10-
assert lib.cffi_func() == 15
10+
assert lib.cffi_func() == 15

0 commit comments

Comments
 (0)