Skip to content

Commit

Permalink
update pre-commits and unpin numba and numpy (#643)
Browse files Browse the repository at this point in the history
  • Loading branch information
giovp committed Feb 17, 2023
1 parent 04eda27 commit 4819abc
Show file tree
Hide file tree
Showing 74 changed files with 705 additions and 653 deletions.
17 changes: 8 additions & 9 deletions .github/.codecov.yml
@@ -1,18 +1,17 @@
# Based on pydata/xarray
codecov:
require_ci_to_pass: no
strict_yaml_branch: main
require_ci_to_pass: false

coverage:
range: 80..100
status:
project:
default:
# Require 1% coverage, i.e., always succeed
target: 1
patch: off
patch: false
changes: false

comment:
layout: reach, diff, files
behavior: default
require_changes: true
branches:
- main
layout: "diff, flags, files"
behavior: once
require_base: false
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Expand Up @@ -90,11 +90,11 @@ jobs:
run: |
tox -vv
- name: Upload coverage
env:
CODECOV_NAME: ${{ matrix.python }}-${{ matrix.os }}
run: |
codecov --no-color --required --flags unittests
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3.1.1
with:
name: coverage
verbose: true

regenerate-notebooks:
needs: test
Expand Down
5 changes: 2 additions & 3 deletions .mypy.ini
Expand Up @@ -28,8 +28,7 @@ show_error_codes = True
show_column_numbers = True
error_summary = True

[mypy-tests.*]
ignore_errors = True
no_namespace_packages = True

[mypy-docs.*]
[mypy-tests.*]
ignore_errors = True
73 changes: 12 additions & 61 deletions .pre-commit-config.yaml
Expand Up @@ -7,45 +7,23 @@ default_stages:
minimum_pre_commit_version: 2.9.3
repos:
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.982
rev: v1.0.0
hooks:
- id: mypy
additional_dependencies:
[numpy==1.21.0, scipy, pandas, types-requests]
exclude: .scripts/ci/download_data.py|squidpy/datasets/_(dataset|image).py # See https://github.com/pre-commit/mirrors-mypy/issues/33
- repo: https://github.com/psf/black
rev: 22.10.0
rev: 23.1.0
hooks:
- id: black
additional_dependencies: [toml]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.2
rev: v3.0.0-alpha.4
hooks:
- id: prettier
- repo: https://github.com/timothycrosley/isort
rev: 5.10.1
hooks:
- id: isort
additional_dependencies: [toml]
args: [--order-by-type]
- repo: https://github.com/asottile/yesqa
rev: v1.4.0
hooks:
- id: yesqa
additional_dependencies:
[
flake8-tidy-imports,
flake8-docstrings,
flake8-rst-docstrings,
flake8-comprehensions,
flake8-bugbear,
flake8-blind-except,
flake8-builtins,
flake8-pytest-style,
flake8-string-format,
]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: detect-private-key
- id: check-merge-conflict
Expand All @@ -67,51 +45,24 @@ repos:
- id: check-yaml
- id: check-toml
- id: requirements-txt-fixer
- repo: https://github.com/myint/autoflake
rev: v1.7.6
hooks:
- id: autoflake
args:
[
--in-place,
--remove-all-unused-imports,
--remove-unused-variable,
--ignore-init-module-imports,
]
- repo: https://github.com/pycqa/flake8.git
rev: 5.0.4
hooks:
- id: flake8
additional_dependencies:
[
flake8-tidy-imports,
flake8-docstrings,
flake8-rst-docstrings,
flake8-comprehensions,
flake8-bugbear,
flake8-blind-except,
flake8-builtins,
flake8-pytest-style,
flake8-string-format,
]
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 3.0.0
hooks:
- id: script-must-have-extension
name: Check executable files use .sh extension
types: [shell, executable]
- repo: https://github.com/asottile/blacken-docs
rev: v1.12.1
rev: 1.13.0
hooks:
- id: blacken-docs
additional_dependencies: [black==20.8b1]
- repo: https://github.com/asottile/pyupgrade
rev: v3.1.0
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: v0.0.246
hooks:
- id: pyupgrade
args: [--py3-plus, --py38-plus, --keep-runtime-typing]
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
rev: v1.10.0
hooks:
- id: python-no-eval
- id: python-use-type-annotations
Expand All @@ -120,6 +71,6 @@ repos:
- id: rst-directive-colons
- id: rst-inline-touching-normal
- repo: https://github.com/PyCQA/doc8
rev: v1.0.0
rev: v1.1.1
hooks:
- id: doc8
6 changes: 3 additions & 3 deletions .scripts/ci/download_data.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
from typing import Any
from pathlib import Path
import argparse
from pathlib import Path
from typing import Any

_CNT = 0 # increment this when you want to rebuild the CI cache
_ROOT = Path.home() / ".cache" / "squidpy"
Expand All @@ -20,7 +20,7 @@ def _maybe_download_data(func_name: str, path: Path) -> Any:

try:
return getattr(sq.datasets, func_name)(path=path)
except Exception as e:
except Exception as e: # noqa: BLE001
print(f"File {str(path):>25} seems to be corrupted: {e}. Removing and retrying")
path.unlink()

Expand Down
5 changes: 3 additions & 2 deletions docs/source/_ext/typed_returns.py
@@ -1,7 +1,8 @@
from typing import List, Iterable, Iterator
import re
from typing import Iterable, Iterator, List

from sphinx.application import Sphinx
from sphinx.ext.napoleon import NumpyDocstring
import re


def _process_return(lines: Iterable[str]) -> Iterator[str]:
Expand Down
16 changes: 8 additions & 8 deletions docs/source/conf.py
Expand Up @@ -4,25 +4,25 @@
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

from pathlib import Path
from datetime import datetime
from sphinx.application import Sphinx
from sphinx_gallery.gen_gallery import DEFAULT_GALLERY_CONF

# -- Path setup --------------------------------------------------------------
import os
import sys
from datetime import datetime
from pathlib import Path

from sphinx.application import Sphinx
from sphinx_gallery.gen_gallery import DEFAULT_GALLERY_CONF

HERE = Path(__file__).parent
sys.path.insert(0, str(HERE.parent.parent)) # this way, we don't have to install squidpy
sys.path.insert(0, os.path.abspath("_ext"))

import squidpy # noqa: E402
from docs.source.utils import ( # noqa: E402
_get_thumbnails,
_fetch_notebooks,
MaybeMiniGallery,
_fetch_notebooks,
_get_thumbnails,
)
import squidpy # noqa: E402

needs_sphinx = "4.0"

Expand Down
11 changes: 6 additions & 5 deletions docs/source/create_news_fragment.py
@@ -1,10 +1,11 @@
import argparse
import logging
import textwrap
from enum import Enum
from typing import Any, List, Mapping, Optional
from pathlib import Path
import logging
import argparse
from typing import Any, List, Mapping, Optional

import requests
import textwrap

_root = Path(__file__).parent / "release" / "changelog"
_valid_types = ("feature", "bugfix", "deprecation", "misc", "doc", "ignore-towncrier")
Expand Down Expand Up @@ -92,7 +93,7 @@ def create_news_fragment(issue_number: str, use_title: bool = False, add_author:
print(add_author, author)
if add_author and author is not None:
print(author, file=fout)
except Exception as e:
except Exception as e: # noqa: BLE001
logging.error(f"Unable to generate news fragment. Reason: `{e}`")
exit(1)

Expand Down
2 changes: 1 addition & 1 deletion docs/source/references.bib
Expand Up @@ -46,7 +46,7 @@ @techreport{networkx
year = {2008},
place = {United States},
institution = {Los Alamos National Lab.(LANL), Los Alamos, NM (United States)},
URL = {https://www.osti.gov/biblio/960616},
URL = {https://conference.scipy.org/proceedings/SciPy2008/paper_2/},
}

@article{tangram,
Expand Down
13 changes: 7 additions & 6 deletions docs/source/utils.py
@@ -1,13 +1,14 @@
from git import Repo
from shutil import rmtree, copytree
from typing import Any, Dict, List, Union, ForwardRef
import os
import re
from logging import info, warning
from pathlib import Path
from shutil import copytree, rmtree
from tempfile import TemporaryDirectory
from typing import Any, Dict, ForwardRef, List, Union

from enchant.tokenize import Filter
from git import Repo
from sphinx_gallery.directives import MiniGallery
import os
import re

HERE = Path(__file__).parent

Expand Down Expand Up @@ -42,7 +43,7 @@ def fetch_local(repo_path: Union[str, Path]) -> None:
)
try:
fetch_local(notebooks_local_path)
except Exception as e:
except Exception as e: # noqa: BLE001
warning(f"Unable to fetch notebooks locally from `{notebooks_local_path}`, reason: `{e}`. Trying remote")
download = int(os.environ.get("SQUIDPY_DOWNLOAD_NOTEBOOKS", 1))
if not download:
Expand Down

0 comments on commit 4819abc

Please sign in to comment.