Skip to content

Commit c3a883a

Browse files
committed
run ruff format . and ruff --check . --fix
- also fix things that couldn't be fixed automatically
1 parent 045b4e2 commit c3a883a

File tree

13 files changed

+620
-594
lines changed

13 files changed

+620
-594
lines changed

docs/source/conf.py

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,51 +12,47 @@
1212

1313
import os
1414
import sys
15-
16-
import sphinx_rtd_theme
1715
from unittest import mock
1816

19-
sys.path.insert(0, os.path.abspath('../../python'))
17+
sys.path.insert(0, os.path.abspath("../../python"))
2018

2119

2220
# -- Project information -----------------------------------------------------
2321

24-
project = 'stempy'
25-
copyright = '2020, Kitware, INC'
26-
author = 'Kitware, INC'
22+
project = "stempy"
23+
copyright = "2020, Kitware, INC"
24+
author = "Kitware, INC"
2725

2826
# The full version, including alpha/beta/rc tags
29-
release = '1.0'
27+
release = "1.0"
3028

3129

3230
# -- General configuration ---------------------------------------------------
3331

3432
# Add any Sphinx extension module names here, as strings. They can be
3533
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3634
# ones.
37-
extensions = [
38-
'sphinx.ext.autodoc',
39-
'sphinx_rtd_theme',
40-
'recommonmark'
41-
]
35+
extensions = ["sphinx.ext.autodoc", "sphinx_rtd_theme", "recommonmark"]
4236

4337
# Add any paths that contain templates here, relative to this directory.
44-
templates_path = ['_templates']
38+
templates_path = ["_templates"]
4539

4640
# List of patterns, relative to source directory, that match files and
4741
# directories to ignore when looking for source files.
4842
# This pattern also affects html_static_path and html_extra_path.
4943
exclude_patterns = []
5044

45+
5146
# Unfortunately, if we have a class that inherits sphinx's mock
5247
# object, and we use that class in a default argument, we run into
5348
# attribute errors. Fix it by defining an explicit mock of the class.
5449
class MockReader:
5550
class H5Format:
5651
Frame = 1
5752

58-
sys.modules['stempy._io'] = mock.Mock()
59-
_io_mock = sys.modules['stempy._io']
53+
54+
sys.modules["stempy._io"] = mock.Mock()
55+
_io_mock = sys.modules["stempy._io"]
6056

6157
# We have to override these so we get don't get conflicting metaclasses
6258
_io_mock._sector_reader = MockReader
@@ -70,36 +66,33 @@ class H5Format:
7066
# The theme to use for HTML and HTML Help pages. See the documentation for
7167
# a list of builtin themes.
7268
#
73-
html_theme = 'sphinx_rtd_theme'
69+
html_theme = "sphinx_rtd_theme"
7470

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

8076
# Get autodoc to mock these imports, because we don't actually need them
8177
# for generating the docs
82-
autodoc_mock_imports = [
83-
'stempy._image',
84-
'numpy',
85-
'h5py'
86-
]
78+
autodoc_mock_imports = ["stempy._image", "numpy", "h5py"]
79+
8780

8881
# Modify this function to customize which classes/functions are skipped
8982
def autodoc_skip_member_handler(app, what, name, obj, skip, options):
9083
# Exclude any names that start with a string in this list
91-
exclude_startswith_list = ['_']
84+
exclude_startswith_list = ["_"]
9285

93-
if any([name.startswith(x) for x in exclude_startswith_list]):
86+
if any(name.startswith(x) for x in exclude_startswith_list):
9487
return True
9588

9689
# Exclude any names that match a string in this list
9790
exclude_names = [
98-
'ReaderMixin',
99-
'PyReader',
100-
'SectorReader',
101-
'get_hdf5_reader',
102-
'SectorThreadedMultiPassReader',
91+
"ReaderMixin",
92+
"PyReader",
93+
"SectorReader",
94+
"get_hdf5_reader",
95+
"SectorThreadedMultiPassReader",
10396
]
10497

10598
return name in exclude_names
@@ -109,4 +102,4 @@ def autodoc_skip_member_handler(app, what, name, obj, skip, options):
109102
def setup(app):
110103
# Connect the autodoc-skip-member event from apidoc to the callback
111104
# This allows us to customize which classes/functions are skipped
112-
app.connect('autodoc-skip-member', autodoc_skip_member_handler)
105+
app.connect("autodoc-skip-member", autodoc_skip_member_handler)

python/stempy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
__version__ = get_version()
44

55
__all__ = [
6-
'__version__',
6+
"__version__",
77
]

python/stempy/contrib/__init__.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ class FileSuffix(Enum):
1818

1919
def check_only_one_filepath(file_path):
2020
if len(file_path) > 1:
21-
raise ValueError(
22-
"Multiple files match that input. Add scan_id to be more specific."
23-
)
21+
raise ValueError("Multiple files match that input. Add scan_id to be more specific.")
2422
elif len(file_path) == 0:
2523
raise FileNotFoundError("No file with those parameters can be found.")
2624

@@ -125,13 +123,9 @@ def get_scan_path_version_1(
125123
if file_suffix == FileSuffix.STANDARD:
126124
file_pattern = f"FOURD_*_{str(scan_id).zfill(5)}_?????.{filetype}"
127125
else:
128-
file_pattern = (
129-
f"FOURD_*_{str(scan_id).zfill(5)}_?????{file_suffix.value}.{filetype}"
130-
)
126+
file_pattern = f"FOURD_*_{str(scan_id).zfill(5)}_?????{file_suffix.value}.{filetype}"
131127
elif scan_num is not None:
132-
file_pattern = (
133-
f"FOURD_*_*_{str(scan_num).zfill(5)}{file_suffix.value}.{filetype}"
134-
)
128+
file_pattern = f"FOURD_*_*_{str(scan_num).zfill(5)}{file_suffix.value}.{filetype}"
135129

136130
file_path = list(directory.glob(file_pattern))
137131
check_only_one_filepath(file_path)
@@ -188,9 +182,7 @@ def get_scan_path(
188182
th=th,
189183
file_suffix=file_suffix,
190184
),
191-
1: lambda: get_scan_path_version_1(
192-
directory, scan_num=scan_num, scan_id=scan_id, file_suffix=file_suffix
193-
),
185+
1: lambda: get_scan_path_version_1(directory, scan_num=scan_num, scan_id=scan_id, file_suffix=file_suffix),
194186
}
195187

196188
for ver in versions_to_try:
@@ -202,6 +194,4 @@ def get_scan_path(
202194
except FileNotFoundError:
203195
continue
204196

205-
raise FileNotFoundError(
206-
"No file with those parameters can be found for any version."
207-
)
197+
raise FileNotFoundError("No file with those parameters can be found for any version.")

0 commit comments

Comments
 (0)