Skip to content

Commit

Permalink
add mypy type checking to actions
Browse files Browse the repository at this point in the history
  • Loading branch information
afrubin committed Aug 26, 2023
1 parent c82cb73 commit ba623af
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
python -m pip install flake8 pytest mypy
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Install package
run: |
Expand All @@ -40,4 +40,7 @@ jobs:
flake8 . --count --exit-zero --statistics
- name: Test with pytest
run: |
pytest
python -m pytest
- name: Type check with mypy
run: |
python -m mypy src/
9 changes: 5 additions & 4 deletions src/fqfa/fastq/fastq.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def parse_fastq_reads(handle: TextIO) -> Generator[FastqRead, None, None]:
raise ValueError("incomplete FASTQ record")
else:
lines = [x.rstrip() for x in lines] # remove trailing newlines
yield FastqRead(*lines)
# TODO: figure out why mypy doesn't like this
yield FastqRead(*lines) # type: ignore[arg-type]


def parse_fastq_pe_reads(
Expand Down Expand Up @@ -80,9 +81,9 @@ def parse_fastq_pe_reads(
for fwd, rev in zip_longest(fwd_generator, rev_generator, fillvalue=None):
if None in (fwd, rev):
raise ValueError("mismatched FASTQ file lengths")
elif fwd.header.split()[0] != rev.header.split()[0]:
elif fwd.header.split()[0] != rev.header.split()[0]: # type: ignore[union-attr]
raise ValueError("forward and reverse read headers do not match")
else:
if revcomp:
rev.reverse_complement()
yield fwd, rev
rev.reverse_complement() # type: ignore[union-attr]
yield fwd, rev # type: ignore[misc]

0 comments on commit ba623af

Please sign in to comment.