Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add mypy type checking to actions #18

Merged
merged 1 commit into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]