Skip to content
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
2 changes: 1 addition & 1 deletion check_typing_linting_and_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def main() -> int:
commands = {
"ruff format": ["ruff", "format", "--check", "--diff", "pyranges1"],
"ruff check": ["ruff", "check", "pyranges1"],
"pyright": ["pyright", "pyranges1"],
"ty": ["ty", "check"],
"pytest": ["pytest", "--doctest-modules", "pyranges1/", "tests/unit/"],
# "more doctest": ["python", "tests/run_doctest_tutorial_howto.py"],
}
Expand Down
27 changes: 13 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ add-ons = [
dev = [
"tox",
"ruff == 0.14.1",
"pyright",
"ty == 0.0.87",
# Cap to the pandas-2.x stub line: unpinned, pandas-stubs resolves to the
# 3.0.x series (which targets pandas 3.0 and changed e.g. the Series.map /
# astype overloads), producing spurious pyright errors against pandas 2.x.
# astype overloads), producing spurious type errors against pandas 2.x.
"pandas-stubs<3",
"types-tabulate",
"pytest-watcher",
Expand Down Expand Up @@ -129,7 +129,7 @@ deps =
pandas-stubs<3
types-tabulate
pytest
pyright == 1.1.406
ty == 0.0.87
joblib
gtfreader >= 0.3.0
ruranges >= 0.1.8
Expand All @@ -138,7 +138,7 @@ deps =
pyarrow
# fisher
commands =
pyright
ty check
python tests/run_doctest_tutorial_howto.py
pytest --doctest-modules pyranges1
pytest tests/unit
Expand Down Expand Up @@ -180,18 +180,17 @@ ignore = [
[tool.pytest-watcher]
now = true

[tool.pyright]
include = ["pyranges1"]
# typeCheckingMode = "strict"
pythonVersion = "3.12"
[tool.ty.environment]
python-version = "3.12"

ignore = ["pyranges1/core/pyranges_groupby.py"]
[tool.ty.src]
include = ["pyranges1"]
exclude = ["pyranges1/core/pyranges_groupby.py"]

# specific rules to disable
reportUnknownParameterType = false
reportUnknownMemberType = false
reportUnknownArgumentType = false
reportUnknownVariableType = false
[tool.ty.analysis]
# optional dependencies that are either compiled without stubs (pyBigWig, gtfreader._parser)
# or not installed in CI
allowed-unresolved-imports = ["pyBigWig", "gtfreader._parser", "fisher", "fire"]

[tool.pytest.ini_options]
markers = [
Expand Down
2 changes: 1 addition & 1 deletion pyranges1/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pyranges1.core.pyranges_helpers import ensure_pyranges

try:
import fire # type: ignore[reportMissingImports]
import fire
except ImportError:
fire = None

Expand Down
10 changes: 5 additions & 5 deletions pyranges1/core/example_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,23 +308,23 @@ def aorta(self) -> "pr.PyRanges":

From the epigenomics roadmap.
"""
return pr.read_bed(ExampleData.files["aorta.bed"]) # type: ignore[index, misc]
return pr.read_bed(ExampleData.files["aorta.bed"])

@property
def aorta2(self) -> "pr.PyRanges":
"""Example ChIP-seq data.

From the epigenomics roadmap.
"""
return pr.read_bed(ExampleData.files["aorta2.bed"]) # type: ignore[index, misc]
return pr.read_bed(ExampleData.files["aorta2.bed"])

@property
def ncbi_gff(self) -> "pr.PyRanges":
"""Example NCBI GFF data.

Subset of the NCBI annotation of D.gyrociliatus assembly GCA_904063045.1.
"""
return pr.read_gff3(ExampleData.files["ncbi.gff.gz"]) # type: ignore[index, misc]
return pr.read_gff3(ExampleData.files["ncbi.gff.gz"])

@property
def ncbi_fasta(self) -> "pyfaidx.Fasta":
Expand All @@ -336,15 +336,15 @@ def ncbi_fasta(self) -> "pyfaidx.Fasta":
To retrieve the location of the fasta file, use pyranges.example_data.files['ncbi.fasta']
"""
try:
import pyfaidx # type: ignore[import]
import pyfaidx
except ImportError:
LOGGER.exception(
"To use this method, pyfaidx must be installed. To get just the fasta file path, use pyranges.example_data.files['ncbi.fasta']. Use `conda install -c bioconda pyfaidx` or `pip install pyfaidx` to install pyfaidx.",
)
sys.exit(1)

# note: example data include ncbi.fasta.fai, the pyfaidx index
return pyfaidx.Fasta(ExampleData.files["ncbi.fasta"]) # type: ignore[index, misc]
return pyfaidx.Fasta(ExampleData.files["ncbi.fasta"])


example_data = ExampleData()
4 changes: 3 additions & 1 deletion pyranges1/core/options.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# below: Class to manage PyRanges options
# purposedly not using a docstring to avoid it being included in the docs

from typing import Any


class PyRangesOptions:
def __init__(self) -> None:
self.options_in_use = {
self.options_in_use: dict[str, tuple[Any, str]] = {
"max_rows_to_show": (8, "the max number of rows to show in PyRanges repr"),
"max_column_names_to_show": (
3,
Expand Down
12 changes: 6 additions & 6 deletions pyranges1/core/out.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

import numpy as np
import pandas as pd
from natsort import natsorted # type: ignore[import]
from natsort import natsorted
from pandas.core.frame import DataFrame

from pyranges1.core.names import BIGWIG_SCORE_COL, CHROM_COL, END_COL, PANDAS_COMPRESSION_TYPE, START_COL
from pyranges1.core.pyranges_helpers import ensure_pyranges
from pyranges1.core.pyranges_main import PyRanges

if TYPE_CHECKING:
from runlength import RleBatch # type: ignore[import-not-found]
from runlength import RleBatch

GTF_COLUMNS_TO_PYRANGES = {
"seqname": "Chromosome",
Expand Down Expand Up @@ -199,7 +199,7 @@ def _to_bed_tabix(df: DataFrame, path: str | Path | None, compression: PANDAS_CO
msg = "tabix=True writes a bgzip-compressed file: give a path ending in .gz or .bgz, and no other compression."
raise ValueError(msg)
try:
import pysam # type: ignore[import]
import pysam
except ImportError:
msg = "pysam must be installed to write a tabix-indexed BED file. Use `pip install pysam`."
raise ImportError(msg) from None
Expand Down Expand Up @@ -238,7 +238,7 @@ def _to_bigwig(
return_data: bool = False,
) -> PyRanges | None:
try:
import pyBigWig # type: ignore[import]
import pyBigWig
except ModuleNotFoundError:
msg = "pybigwig must be installed to create bigwigs. Use `conda install -c bioconda pybigwig` or `pip install pybigwig` to install it."
raise ImportError(msg) from None
Expand Down Expand Up @@ -532,7 +532,7 @@ def _to_bigbed(
autosql: str | None = None,
) -> None:
try:
import pybigtools # type: ignore[import]
import pybigtools
except ImportError:
msg = "pybigtools must be installed to write BigBed files. Use `pip install pybigtools` to install it."
raise ImportError(msg) from None
Expand Down Expand Up @@ -566,5 +566,5 @@ def _to_bigbed(
sql = autosql

ordered_sizes = {c: sizes[c] for c in sorted(sizes)}
writer = pybigtools.open(str(path), "w") # type: ignore[attr-defined]
writer = pybigtools.open(str(path), "w")
writer.write(ordered_sizes, iter(vals), autosql=sql)
Loading
Loading