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 automerge bot for dependabot and pre-commit.ci PRs #2

Merged
merged 4 commits into from
Dec 10, 2024
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
21 changes: 21 additions & 0 deletions .github/workflows/bot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: bot
concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.ref }}
cancel-in-progress: true
on: # yamllint disable-line rule:truthy
pull_request

permissions:
contents: write
pull-requests: write

jobs:
auto-merge:
runs-on: ubuntu-latest
if: (github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.user.login == 'pre-commit-ci[bot]') && github.repository == 'fcbg-platforms/nmod-wiki'
steps:
- name: Enable auto-merge for bot PRs
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50 changes: 17 additions & 33 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,22 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
python-version: [3.9, "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
name: ${{ matrix.os }} - py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}-latest
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install package
run: |
python -m pip install --progress-bar off --upgrade pip setuptools
python -m pip install --progress-bar off .[test]
- name: Display system information
run: nmod-wiki sys-info --developer
- name: Run pytest
run: pytest nmod_wiki --cov=nmod_wiki --cov-report=xml --cov-config=pyproject.toml
- name: Upload to codecov
uses: codecov/codecov-action@v5
- uses: astral-sh/setup-uv@v4
- run: uv pip install --quiet --system .[test]
- run: nmod-wiki sys-info --developer
- run: pytest nmod_wiki --cov=nmod_wiki --cov-report=xml --cov-config=pyproject.toml
- uses: codecov/codecov-action@v5
with:
files: ./coverage.xml
flags: unittests # optional
Expand All @@ -55,27 +48,18 @@ jobs:
python-version: ["3.11"]
name: pip pre-release - py${{ matrix.python-version }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --progress-bar off --upgrade pip setuptools
python -m pip install --progress-bar off .[test]
python -m pip install --progress-bar off --upgrade --pre --only-binary :all: -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple --timeout=180 numpy
- name: Display system information
run: nmod-wiki sys-info --developer
- name: Run pytest
run: pytest nmod_wiki --cov=nmod_wiki --cov-report=xml --cov-config=pyproject.toml
- name: Upload to codecov
uses: codecov/codecov-action@v5
- uses: astral-sh/setup-uv@v4
- run: |
uv pip install --quiet --system .[test]
uv pip install --quiet --system --upgrade --prerelease allow --only-binary :all: -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy
- run: nmod-wiki sys-info --developer
- run: pytest nmod_wiki --cov=nmod_wiki --cov-report=xml --cov-config=pyproject.toml
- uses: codecov/codecov-action@v5
with:
files: ./coverage.xml
flags: unittests # optional
Expand Down
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import nmod_wiki

if TYPE_CHECKING:
from typing import Optional
pass

# -- project information ---------------------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
Expand Down Expand Up @@ -187,7 +187,7 @@
# https://www.sphinx-doc.org/en/master/usage/extensions/linkcode.html


def linkcode_resolve(domain: str, info: dict[str, str]) -> Optional[str]:
def linkcode_resolve(domain: str, info: dict[str, str]) -> str | None:
"""Determine the URL corresponding to a Python object.

Parameters
Expand Down
12 changes: 6 additions & 6 deletions nmod_wiki/utils/_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
from ._docs import fill_doc

if TYPE_CHECKING:
from typing import Any, Optional, Union
from typing import Any


def ensure_int(item: Any, item_name: Optional[str] = None) -> int:
def ensure_int(item: Any, item_name: str | None = None) -> int:
"""Ensure a variable is an integer.

Parameters
Expand Down Expand Up @@ -72,7 +72,7 @@ def __instancecheck__(cls, other: Any) -> bool:
}


def check_type(item: Any, types: tuple, item_name: Optional[str] = None) -> None:
def check_type(item: Any, types: tuple, item_name: str | None = None) -> None:
"""Check that item is an instance of types.

Parameters
Expand Down Expand Up @@ -127,9 +127,9 @@ def check_type(item: Any, types: tuple, item_name: Optional[str] = None) -> None

def check_value(
item: Any,
allowed_values: Union[tuple, dict[Any, Any]],
item_name: Optional[str] = None,
extra: Optional[str] = None,
allowed_values: tuple | dict[Any, Any],
item_name: str | None = None,
extra: str | None = None,
) -> None:
"""Check the value of a parameter against a list of valid options.

Expand Down
3 changes: 2 additions & 1 deletion nmod_wiki/utils/_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from typing import Any, Callable
from collections.abc import Callable
from typing import Any

# -- Documentation dictionary ----------------------------------------------------------
docdict: dict[str, str] = dict()
Expand Down
3 changes: 2 additions & 1 deletion nmod_wiki/utils/_docs.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, Callable
from collections.abc import Callable
from typing import Any

docdict: dict[str, str]
docdict_indented: dict[int, dict[str, str]]
Expand Down
3 changes: 1 addition & 2 deletions nmod_wiki/utils/_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

if TYPE_CHECKING:
from types import ModuleType
from typing import Optional

# A mapping from import name to package name (on PyPI) when the package name
# is different.
Expand All @@ -29,7 +28,7 @@ def import_optional_dependency(
name: str,
extra: str = "",
raise_error: bool = True,
) -> Optional[ModuleType]:
) -> ModuleType | None:
"""Import an optional dependency.

By default, if a dependency is missing an ImportError with a nice message will be
Expand Down
7 changes: 4 additions & 3 deletions nmod_wiki/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
from ._checks import check_type

if TYPE_CHECKING:
from typing import IO, Callable, Optional
from collections.abc import Callable
from typing import IO


def sys_info(fid: Optional[IO] = None, developer: bool = False):
def sys_info(fid: IO | None = None, developer: bool = False):
"""Print the system information for debugging.

Parameters
Expand Down Expand Up @@ -134,7 +135,7 @@ def _list_dependencies_info(


@lru_cache(maxsize=1)
def _get_gpu_info() -> tuple[Optional[str], Optional[str]]:
def _get_gpu_info() -> tuple[str | None, str | None]:
"""Get the GPU information."""
try:
from pyvista import GPUInfo
Expand Down
3 changes: 2 additions & 1 deletion nmod_wiki/utils/config.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import IO, Callable
from collections.abc import Callable
from typing import IO

from packaging.requirements import Requirement

Expand Down
16 changes: 8 additions & 8 deletions nmod_wiki/utils/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
from ._fixes import WrapStdOut

if TYPE_CHECKING:
from typing import Callable, Optional, Union
from collections.abc import Callable


_PACKAGE: str = __package__.split(".")[0]


@fill_doc
def _init_logger(*, verbose: Optional[Union[bool, str, int]] = None) -> logging.Logger:
def _init_logger(*, verbose: bool | str | int | None = None) -> logging.Logger:
"""Initialize a logger.

Assigns sys.stdout as the first handler of the logger.
Expand All @@ -47,11 +47,11 @@ def _init_logger(*, verbose: Optional[Union[bool, str, int]] = None) -> logging.


def add_file_handler(
fname: Union[str, Path],
fname: str | Path,
mode: str = "a",
encoding: Optional[str] = None,
encoding: str | None = None,
*,
verbose: Optional[Union[bool, str, int]] = None,
verbose: bool | str | int | None = None,
) -> None:
"""Add a file handler to the logger.

Expand Down Expand Up @@ -83,7 +83,7 @@ def add_file_handler(


@fill_doc
def set_log_level(verbose: Optional[Union[bool, str, int]]) -> None:
def set_log_level(verbose: bool | str | int | None) -> None:
"""Set the log level for the logger.

Parameters
Expand Down Expand Up @@ -167,7 +167,7 @@ class _use_log_level: # noqa: N801
%(verbose)s
"""

def __init__(self, verbose: Optional[Union[bool, str, int]] = None):
def __init__(self, verbose: bool | str | int | None = None):
self._old_level = logger.level
self._level = verbose

Expand All @@ -182,7 +182,7 @@ def warn(
message: str,
category: Warning = RuntimeWarning,
module: str = _PACKAGE,
ignore_namespaces: Union[tuple[str, ...] | list[str]] = (_PACKAGE,),
ignore_namespaces: tuple[str, ...] | list[str] = (_PACKAGE,),
) -> None:
"""Emit a warning with trace outside the requested namespace.

Expand Down
2 changes: 1 addition & 1 deletion nmod_wiki/utils/logs.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from collections.abc import Callable
from pathlib import Path
from typing import Callable

from _typeshed import Incomplete

Expand Down
7 changes: 3 additions & 4 deletions nmod_wiki/utils/tests/test_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

if TYPE_CHECKING:
from pathlib import Path
from typing import Optional, Union


def test_default_log_level(caplog: pytest.LogCaptureFixture):
Expand Down Expand Up @@ -68,7 +67,7 @@ def test_verbose(caplog: pytest.LogCaptureFixture):

# function
@verbose
def foo(verbose: Optional[Union[bool, str, int]] = None):
def foo(verbose: bool | str | int | None = None):
"""Foo function."""
logger.debug("101")

Expand All @@ -94,12 +93,12 @@ def __init__(self):
pass

@verbose
def foo(self, verbose: Optional[Union[bool, str, int]] = None):
def foo(self, verbose: bool | str | int | None = None):
logger.debug("101")

@staticmethod
@verbose
def foo2(verbose: Optional[Union[bool, str, int]] = None):
def foo2(verbose: bool | str | int | None = None):
logger.debug("101")

foo = Foo()
Expand Down
9 changes: 3 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ classifiers = [
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.13',
]
dependencies = [
'click',
Expand All @@ -38,7 +38,7 @@ maintainers = [
]
name = 'nmod_wiki'
readme = 'README.md'
requires-python = '>=3.9'
requires-python = '>=3.10'
version = '0.1.0'

[project.optional-dependencies]
Expand Down Expand Up @@ -128,7 +128,7 @@ minversion = '8.0'
[tool.ruff]
extend-exclude = []
line-length = 88
target-version = 'py39'
target-version = 'py310'

[tool.ruff.format]
docstring-code-format = true
Expand All @@ -138,15 +138,12 @@ line-ending = "lf"
ignore = []
select = ['A', 'B', 'D', 'E', 'F', 'G', 'I', 'LOG', 'NPY', 'PIE', 'PT', 'T20', 'UP', 'W']


[tool.ruff.lint.per-file-ignores]
'*' = [
'B904', # 'Within an except clause, raise exceptions with raise ... from ...'
'D100', # 'Missing docstring in public module'
'D104', # 'Missing docstring in public package'
'D107', # 'Missing docstring in __init__'
'UP007', # 'Use `X | Y` for type annotations', requires python 3.10
'UP038', # 'Use X | Y in {} call instead of (X, Y)', requires python 3.10
]
'*.pyi' = ['E501']
'__init__.py' = ['F401']
Expand Down
2 changes: 1 addition & 1 deletion tools/stubgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
objects = [
node
for node in module_ast.body
if isinstance(node, (ast.ClassDef, ast.FunctionDef))
if isinstance(node, (ast.ClassDef | ast.FunctionDef))
]
for node in objects:
docstring = getattr(module, node.name).__doc__
Expand Down
Loading