Skip to content

Commit

Permalink
Fix Mypy errors and move Mypy config to pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
vnmabus committed Jan 22, 2024
1 parent 1bcbd1b commit e9b3d50
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 26 deletions.
4 changes: 3 additions & 1 deletion examples/plot_cran.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@
with tarfile.open(fileobj=package, mode="r|gz") as package_tar:
for member in package_tar:
if member.name == data_path:
with package_tar.extractfile(member) as dataset:
dataset = package_tar.extractfile(member)
assert dataset
with dataset:
parsed = rdata.parser.parse_file(dataset)
break

Expand Down
21 changes: 20 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,23 @@ combine-as-imports = true
convention = "google"

[tool.ruff.lint.pylint]
max-args = 7
max-args = 7

[tool.mypy]
strict = true
strict_equality = true
implicit_reexport = true

[[tool.mypy.overrides]]
module = [
"igraph.*",
"ipywidgets.*",
"numpy.*",
"pandas.*",
"setuptools.*",
]
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = "examples.*"
disallow_untyped_defs = false
2 changes: 1 addition & 1 deletion rdata/tests/test_rdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class SimpleTests(unittest.TestCase):

def test_opened_file(self) -> None:
"""Test that an opened file can be passed to parse_file."""
with (TESTDATA_PATH / "test_vector.rda").open() as f:
with (TESTDATA_PATH / "test_vector.rda").open("rb") as f:
parsed = rdata.parser.parse_file(f)
converted = rdata.conversion.convert(parsed)

Expand Down
23 changes: 0 additions & 23 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,3 @@ include_trailing_comma = true
use_parentheses = true
combine_as_imports = 1
skip_glob = **/plot_*.py plot_*.py

[mypy]
strict = True
strict_equality = True
implicit_reexport = True

[mypy-igraph.*]
ignore_missing_imports = True

[mypy-ipywidgets.*]
ignore_missing_imports = True

[mypy-numpy.*]
ignore_missing_imports = True

[mypy-pandas.*]
ignore_missing_imports = True

[mypy-setuptools.*]
ignore_missing_imports = True

[mypy-examples.*]
disallow_untyped_defs = False

0 comments on commit e9b3d50

Please sign in to comment.