Skip to content

Commit c2e4cdf

Browse files
committed
Fix mypy errors outside of lib/
1 parent e8fe545 commit c2e4cdf

File tree

10 files changed

+31
-21
lines changed

10 files changed

+31
-21
lines changed

doc/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
]
2626

2727
templates_path = ["_templates"]
28-
exclude_patterns = ()
28+
exclude_patterns: list[str] = []
2929

3030

3131
# -- Options for HTML output -------------------------------------------------

scripts/bed_coverage.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@
1010

1111
import fileinput
1212
import sys
13+
from typing import (
14+
TextIO,
15+
Union,
16+
)
1317

1418
from bx.bitset_builders import binned_bitsets_from_file
1519

1620
bed_filenames = sys.argv[1:]
1721
if bed_filenames:
18-
input = fileinput.input(bed_filenames)
22+
input: Union[fileinput.FileInput, TextIO] = fileinput.input(bed_filenames)
1923
else:
2024
input = sys.stdin
2125

scripts/bed_merge_overlapping.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@
1010

1111
import fileinput
1212
import sys
13+
from typing import (
14+
TextIO,
15+
Union,
16+
)
1317

1418
from bx.bitset_builders import binned_bitsets_from_bed_file
1519

1620
bed_filenames = sys.argv[1:]
1721
if bed_filenames:
18-
input = fileinput.input(bed_filenames)
22+
input: Union[fileinput.FileInput, TextIO] = fileinput.input(bed_filenames)
1923
else:
2024
input = sys.stdin
2125

scripts/bnMapper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import numpy as np
2121

2222
from bx.align import epo
23-
from bx.align.epo import bed_union as elem_u
23+
from bx.align.epo import bed_union as elem_u # type: ignore[attr-defined]
2424
from bx.intervals.intersection import (
2525
Interval,
2626
IntervalTree,
@@ -427,6 +427,6 @@ def loadFeatures(path, opt):
427427
outpath = os.path.join(opt.output, os.path.basename(inpath))
428428
if os.path.isfile(outpath):
429429
log.warning("overwriting %s ...", outpath)
430-
transform_file(loadFeatures(inpath), outpath, EPO, TREE, opt)
430+
transform_file(loadFeatures(inpath, opt), outpath, EPO, TREE, opt)
431431
else:
432432
transform_file(loadFeatures(opt.input[0], opt), opt.output, EPO, TREE, opt)

scripts/gene_fourfold_sites.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ def translate(codon, genetic_code):
9494

9595

9696
""" parse the doc string to hash the genetic code"""
97-
GEN_CODE = {}
97+
GEN_CODE: dict[str, dict[str, dict[str, str]]] = {}
9898
for line in GENETIC_CODE.split("\n"):
9999
if line.strip() == "":
100100
continue
101101
f = re.split(r"\s|\(|\)|\/", line)
102102
codon = f[0]
103-
c1, c2, c3 = codon
103+
c1, c2, c3 = list(codon)
104104
aminoacid = f[3]
105105
if c1 not in GEN_CODE:
106106
GEN_CODE[c1] = {}

scripts/maf_col_counts.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import bx.align.maf
1616

17-
counts = {}
17+
counts: dict[tuple, int] = {}
1818

1919
nspecies = None
2020

@@ -31,8 +31,8 @@
3131
except Exception:
3232
counts[col] = 1
3333

34-
counts = sorted((value, key) for key, value in counts.items())
35-
counts.reverse()
34+
sorted_counts = sorted((value, key) for key, value in counts.items())
35+
sorted_counts.reverse()
3636

37-
for count, col in counts:
37+
for count, col in sorted_counts:
3838
print("".join(col), count)

scripts/maf_col_counts_all.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,25 @@
2222
doc_optparse,
2323
)
2424

25-
counts = {}
25+
counts: dict[str, int] = {}
2626

2727
nspecies = None
2828

2929
for block in bx.align.maf.Reader(sys.stdin):
3030
# Ensure all blocks have the same number of rows
31-
if nspecies:
31+
if nspecies is not None:
3232
assert len(block.components) == nspecies
3333
else:
3434
nspecies = len(block.components)
3535
# Increment count for each column
36-
for col in zip(*[iter(comp.text.upper()) for comp in block.components]):
37-
col = "".join(col)
36+
for col_tuple in zip(*[iter(comp.text.upper()) for comp in block.components]):
37+
col = "".join(col_tuple)
3838
try:
3939
counts[col] += 1
4040
except Exception:
4141
counts[col] = 1
4242

43+
assert nspecies is not None
4344
options, args = doc_optparse.parse(__doc__)
4445

4546
wildcard = False
@@ -54,8 +55,8 @@
5455
if wildcard:
5556
nucs += "*"
5657

57-
for col in cross_lists(*([nucs] * nspecies)):
58-
col = "".join(col)
58+
for col_list in cross_lists(*([nucs] * nspecies)):
59+
col = "".join(col_list)
5960
if wildcard and col.count("*") > max_wildcard:
6061
continue
6162
if col.count("-") == nspecies:

scripts/tfloc_summary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import sys
1111
from collections import defaultdict
1212

13-
counts = defaultdict(int)
13+
counts: dict[int, int] = defaultdict(int)
1414

1515
max_index = -1
1616

scripts/wiggle_to_simple.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@
77
"""
88

99
import sys
10+
from typing import TextIO
1011

1112
import bx.wiggle
1213

1314
if len(sys.argv) > 1:
14-
in_file = open(sys.argv[1])
15+
in_file: TextIO = open(sys.argv[1])
1516
else:
1617
in_file = sys.stdin
1718

1819
if len(sys.argv) > 2:
19-
out_file = open(sys.argv[2], "w")
20+
out_file: TextIO = open(sys.argv[2], "w")
2021
else:
2122
out_file = sys.stdout
2223

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ commands =
88
lint: flake8 .
99
lint: black --check --diff .
1010
lint: isort --check --diff .
11-
lint: mypy lib/
11+
lint: mypy .
1212
deps =
1313
test: Cython
1414
test: numpy

0 commit comments

Comments
 (0)