Skip to content

Commit 877efed

Browse files
authored
Merge pull request #763 from padix-key/ruff
Update ruff version
2 parents cc199ab + b17a123 commit 877efed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+92
-109
lines changed

.github/workflows/test_and_deploy.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
python-version: "3.12"
4747
- name: Install ruff
4848
# Keep in sync with the corresponding versions in pyproject.toml
49-
run: pip install ruff==0.6.9 numpydoc==1.8.0
49+
run: pip install ruff==0.9.7 numpydoc==1.8.0
5050
- name: Check code formatting
5151
run: ruff format --diff
5252
- name: Lint code base

doc/apidoc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def _create_package_page(doc_path, package_name, classes, functions, subpackages
119119
string = dedent(f"""
120120
121121
{category}
122-
{"-"*len(category)}
122+
{"-" * len(category)}
123123
124124
.. autosummary::
125125
:nosignatures:

doc/examples/scripts/sequence/annotation/sigma_domains.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
ax.text(
112112
x=(last + first) / 2,
113113
y=i,
114-
s=rf"$\sigma_{j+1}$",
114+
s=rf"$\sigma_{j + 1}$",
115115
ha="center",
116116
va="center",
117117
)

doc/examples/scripts/structure/modeling/docking.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
correlation, p_value = spearmanr(energies, rmsd)
108108

109109
figure, ax = plt.subplots(figsize=(8.0, 6.0))
110-
ax.set_title(f"$r_s$ = {correlation:.2f} ($p$ = {p_value*100:.1f}%)")
110+
ax.set_title(f"$r_s$ = {correlation:.2f} ($p$ = {p_value * 100:.1f}%)")
111111
ax.scatter(energies, rmsd, marker="+", color="black")
112112
ax.set_xlabel("Energy (kcal/mol)")
113113
ax.set_ylabel("RMSD (Å)")

environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ dependencies:
2828
- pytest >=7.0
2929
- pytest-codspeed >=2.0
3030
# Code style, keep in sync with the versions in pyproject.toml
31-
- ruff =0.6.9
31+
- ruff =0.9.7
3232
- numpydoc =1.8.0
3333
# Interfaced software in biotite.application (can also be installed separately)
3434
- autodock-vina

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ test = [
3737
"pytest-codspeed",
3838
]
3939
lint = [
40-
"ruff == 0.6.9",
40+
"ruff == 0.9.7",
4141
"numpydoc == 1.8.0",
4242
]
4343

src/biotite/application/application.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def join(self, timeout=None):
157157
if timeout is not None and time.time() - self._start_time > timeout:
158158
self.cancel()
159159
raise TimeoutError(
160-
f"The application expired its timeout " f"({timeout:.1f} s)"
160+
f"The application expired its timeout ({timeout:.1f} s)"
161161
)
162162
else:
163163
time.sleep(self.wait_interval())

src/biotite/application/clustalo/app.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def get_distance_matrix(self):
172172
"""
173173
if self._mbed:
174174
raise ValueError(
175-
"Getting the distance matrix requires " "'full_matrix_calculation()'"
175+
"Getting the distance matrix requires 'full_matrix_calculation()'"
176176
)
177177
return self._dist_matrix
178178

src/biotite/application/localapp.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ def evaluate(self):
279279
if exit_code != 0:
280280
err_msg = self.get_stderr().replace("\n", " ")
281281
raise SubprocessError(
282-
f"'{self._bin_path}' returned with exit code {exit_code}: " f"{err_msg}"
282+
f"'{self._bin_path}' returned with exit code {exit_code}: {err_msg}"
283283
)
284284

285285
def clean_up(self):

src/biotite/application/msaapp.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def __init__(self, sequences, bin_path, matrix=None):
6868
# Check matrix symmetry
6969
if matrix is not None and not matrix.is_symmetric():
7070
raise ValueError(
71-
"A symmetric matrix is required for " "multiple sequence alignments"
71+
"A symmetric matrix is required for multiple sequence alignments"
7272
)
7373

7474
# Check whether the program supports the alignment for the given

src/biotite/application/util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def map_matrix(matrix):
6363
"""
6464
if matrix is None:
6565
raise TypeError(
66-
"A substitution matrix must be provided for custom " "sequence types"
66+
"A substitution matrix must be provided for custom sequence types"
6767
)
6868
# Create a protein substitution matrix with the values taken
6969
# from the original matrix

src/biotite/database/entrez/download.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def fetch(
110110
for i, id in enumerate(uids):
111111
# Verbose output
112112
if verbose:
113-
print(f"Fetching file {i+1:d} / {len(uids):d} ({id})...", end="\r")
113+
print(f"Fetching file {i + 1:d} / {len(uids):d} ({id})...", end="\r")
114114
# Fetch file from database
115115
if target_path is not None:
116116
file = join(target_path, id + "." + suffix)

src/biotite/database/entrez/query.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ class SimpleQuery(Query):
173173
"SUBS",
174174
"WORD",
175175
"TI",
176-
"TITL" "VOL",
176+
"TITL",
177+
"VOL",
177178
]
178179

179180
def __init__(self, term, field=None):

src/biotite/database/pubchem/download.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def fetch(
114114
raise TypeError("CIDs must be given as integers, not as string")
115115
# Verbose output
116116
if verbose:
117-
print(f"Fetching file {i+1:d} / {len(cids):d} ({cid})...", end="\r")
117+
print(f"Fetching file {i + 1:d} / {len(cids):d} ({cid})...", end="\r")
118118

119119
# Fetch file from database
120120
if target_path is not None:

src/biotite/database/pubchem/query.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ def __init__(self, **kwargs):
332332
)
333333
if not query_key_found:
334334
raise TypeError(
335-
"Expected exactly one of 'smiles', 'smarts', 'inchi', 'sdf' " "or 'cid'"
335+
"Expected exactly one of 'smiles', 'smarts', 'inchi', 'sdf' or 'cid'"
336336
)
337337
if "number" in kwargs:
338338
self._number = kwargs["number"]

src/biotite/database/rcsb/download.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def fetch(pdb_ids, format, target_path=None, overwrite=False, verbose=False):
9191
for i, id in enumerate(pdb_ids):
9292
# Verbose output
9393
if verbose:
94-
print(f"Fetching file {i+1:d} / {len(pdb_ids):d} ({id})...", end="\r")
94+
print(f"Fetching file {i + 1:d} / {len(pdb_ids):d} ({id})...", end="\r")
9595

9696
# Fetch file from database
9797
if target_path is not None:

src/biotite/database/rcsb/query.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def __init__(
257257
"exists",
258258
]:
259259
raise TypeError(
260-
f"Constructor got an unexpected keyword argument " f"'{self._operator}'"
260+
f"Constructor got an unexpected keyword argument '{self._operator}'"
261261
)
262262

263263
# Convert dates into ISO 8601
@@ -944,8 +944,7 @@ def _initialize_query_dict(query, return_type, group_by, content_types):
944944
if group_by is not None:
945945
if not group_by.is_compatible_return_type(return_type):
946946
raise ValueError(
947-
f"Return type '{return_type}' is not compatible "
948-
f"with the given Grouping"
947+
f"Return type '{return_type}' is not compatible with the given Grouping"
949948
)
950949
request_options["group_by"] = group_by.get_content()
951950

src/biotite/interface/pymol/cgo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def get_multiline_cgo(start, end, color, width=1.0):
304304

305305
if len(start) != len(end):
306306
raise IndexError(
307-
f"{len(start)} start positions are given, " f"but {len(end)} end positions"
307+
f"{len(start)} start positions are given, but {len(end)} end positions"
308308
)
309309
for p in start:
310310
_expect_length(p, "start", 3)

src/biotite/interface/pymol/object.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def exists(self):
303303
def _check_existence(self):
304304
if not self.exists():
305305
raise NonexistentObjectError(
306-
f"A PyMOL object with the name {self._name} " f"does not exist anymore"
306+
f"A PyMOL object with the name {self._name} does not exist anymore"
307307
)
308308

309309
@validate
@@ -371,7 +371,7 @@ def where(self, index):
371371
# - PyMOLs indexing starts at 1-> 'start+1'
372372
# - Stop in 'intervals' is exclusive -> 'stop+1-1' -> 'stop'
373373
index_selection = " or ".join(
374-
[f"index {start+1}-{stop}" for start, stop in intervals]
374+
[f"index {start + 1}-{stop}" for start, stop in intervals]
375375
)
376376
# Constrain the selection to given object name
377377
return f"%{self._name} and ({index_selection})"

src/biotite/interface/pymol/shapes.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ def draw_arrows(
7171
raise IndexError("Expected 2D array for start and end positions")
7272
if len(start) != len(end):
7373
raise IndexError(
74-
f"Got {len(start)} start positions, "
75-
f"but expected {len(end)} end positions"
74+
f"Got {len(start)} start positions, but expected {len(end)} end positions"
7675
)
7776
expected_length = len(start)
7877
radius = _arrayfy(radius, expected_length, 1)

src/biotite/sequence/align/matrix.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def __init__(self, alphabet1, alphabet2, score_matrix):
173173
self._fill_with_matrix_dict(matrix_dict)
174174
else:
175175
raise TypeError(
176-
"Matrix must be either a dictionary, " "an 2-D ndarray or a string"
176+
"Matrix must be either a dictionary, an 2-D ndarray or a string"
177177
)
178178
# This class is immutable and has a getter function for the
179179
# score matrix -> make the score matrix read-only
@@ -442,7 +442,7 @@ def __str__(self):
442442
for i, symbol in enumerate(self._alph1):
443443
string += f"{str(symbol):>1}"
444444
for j in range(len(self._alph2)):
445-
string += f" {int(self._matrix[i,j]):>3d}"
445+
string += f" {int(self._matrix[i, j]):>3d}"
446446
string += "\n"
447447
# Remove terminal line break
448448
string = string[:-1]

src/biotite/sequence/align/statistics.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def from_samples(
168168
raise ValueError("A symmetric substitution matrix is required")
169169
if not matrix.get_alphabet1().extends(alphabet):
170170
raise ValueError(
171-
"The substitution matrix is not compatible " "with the given alphabet"
171+
"The substitution matrix is not compatible with the given alphabet"
172172
)
173173
score_matrix = matrix.score_matrix()[: len(alphabet), : len(alphabet)]
174174
if (

src/biotite/sequence/annotation.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ def __init__(self, first, last, strand=Strand.FORWARD, defect=Defect.NONE):
9797
def __repr__(self):
9898
"""Represent Location as a string for debugging."""
9999
return (
100-
f'Location({self._first}, {self._last}, strand={"Location." + str(self._strand)}, '
101-
f'defect={"Location." + str(self._defect)})'
100+
f"Location({self._first}, {self._last}, strand={'Location.' + str(self._strand)}, "
101+
f"defect={'Location.' + str(self._defect)})"
102102
)
103103

104104
@property
@@ -361,7 +361,7 @@ def __init__(self, features=None):
361361
def __repr__(self):
362362
"""Represent Annotation as a string for debugging."""
363363
return (
364-
f'Annotation([{", ".join([feat.__repr__() for feat in self._features])}])'
364+
f"Annotation([{', '.join([feat.__repr__() for feat in self._features])}])"
365365
)
366366

367367
def __copy_create__(self):
@@ -389,8 +389,7 @@ def add_feature(self, feature):
389389
"""
390390
if not isinstance(feature, Feature):
391391
raise TypeError(
392-
f"Only 'Feature' objects are supported, "
393-
f"not {type(feature).__name__}"
392+
f"Only 'Feature' objects are supported, not {type(feature).__name__}"
394393
)
395394
self._features.add(feature)
396395

@@ -503,7 +502,7 @@ def __getitem__(self, index):
503502
def __delitem__(self, item):
504503
if not isinstance(item, Feature):
505504
raise TypeError(
506-
f"Only 'Feature' objects are supported, " f"not {type(item).__name__}"
505+
f"Only 'Feature' objects are supported, not {type(item).__name__}"
507506
)
508507
self.del_feature(item)
509508

src/biotite/sequence/io/fasta/convert.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,7 @@ def _process_nucleotide_sequence(x):
275275
def _convert_to_string(sequence, as_rna):
276276
if not isinstance(sequence.get_alphabet(), LetterAlphabet):
277277
raise ValueError(
278-
"Only sequences using single letter alphabets "
279-
"can be stored in a FASTA file"
278+
"Only sequences using single letter alphabets can be stored in a FASTA file"
280279
)
281280
if isinstance(sequence, NucleotideSequence) and as_rna:
282281
return str(sequence).replace("T", "U")

src/biotite/sequence/io/fasta/file.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def __setitem__(self, header, seq_str):
102102
if not isinstance(header, str):
103103
raise IndexError("'FastaFile' only supports header strings as keys")
104104
if not isinstance(seq_str, str):
105-
raise TypeError("'FastaFile' only supports sequence strings " "as values")
105+
raise TypeError("'FastaFile' only supports sequence strings as values")
106106
# Create lines for new header and sequence (with line breaks)
107107
new_lines = [">" + header.replace("\n", "").strip()] + wrap_string(
108108
seq_str, width=self._chars_per_line

src/biotite/sequence/io/fastq/file.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,10 @@ def _find_entries(self):
302302
else: # score_len > seq_len
303303
raise InvalidFileError(
304304
f"The amount of scores is not equal to the sequence "
305-
f"length for the sequence in line {seq_start_i+1} "
305+
f"length for the sequence in line {seq_start_i + 1} "
306306
)
307307
else:
308-
raise InvalidFileError(f"Line {i+1} in FASTQ file is invalid")
308+
raise InvalidFileError(f"Line {i + 1} in FASTQ file is invalid")
309309
# At the end of the file, the last sequence or score block
310310
# must have properly ended
311311
if in_sequence or in_scores:
@@ -392,7 +392,7 @@ def read_iter(file, offset):
392392
yield identifier, ("".join(seq_str_list), scores)
393393
else: # score_len > seq_len
394394
raise InvalidFileError(
395-
"The amount of scores is not equal to the sequence " "length"
395+
"The amount of scores is not equal to the sequence length"
396396
)
397397

398398
else:

src/biotite/sequence/io/gff/convert.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def set_annotation(gff_file, annotation, seqid=None, source=None, is_stranded=Tr
8484
for feature in sorted(annotation):
8585
if len(feature.locs) > 1 and "ID" not in feature.qual:
8686
raise ValueError(
87-
"The 'Id' qualifier is required " "for features with multiple locations"
87+
"The 'Id' qualifier is required for features with multiple locations"
8888
)
8989
## seqid ##
9090
if seqid is not None and " " in seqid:

src/biotite/sequence/io/gff/file.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,7 @@ def __setitem__(self, index, item):
303303
def __getitem__(self, index):
304304
if (index >= 0 and index >= len(self)) or (index < 0 and -index > len(self)):
305305
raise IndexError(
306-
f"Index {index} is out of range for GFFFile with "
307-
f"{len(self)} entries"
306+
f"Index {index} is out of range for GFFFile with {len(self)} entries"
308307
)
309308

310309
line_index = self._entries[index]

src/biotite/sequence/seqtypes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ def get_molecular_weight(self, monoisotopic=False):
601601

602602
if np.isnan(weight):
603603
raise ValueError(
604-
"Sequence contains ambiguous amino acids, " "cannot calculate weight"
604+
"Sequence contains ambiguous amino acids, cannot calculate weight"
605605
)
606606
return weight
607607

src/biotite/structure/alphabet/unkerasify.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def read(self):
7171
(w1,) = self._get("I")
7272
(b0,) = self._get("I")
7373
weights = (
74-
np.frombuffer(self._read(f"={w0*w1}f"), dtype="f4")
74+
np.frombuffer(self._read(f"={w0 * w1}f"), dtype="f4")
7575
.reshape(w0, w1)
7676
.copy()
7777
)

0 commit comments

Comments
 (0)