Skip to content

Commit

Permalink
feat: py312
Browse files Browse the repository at this point in the history
  • Loading branch information
klen committed Jul 31, 2024
1 parent 79d7482 commit 31e0783
Show file tree
Hide file tree
Showing 7 changed files with 366 additions and 284 deletions.
36 changes: 36 additions & 0 deletions .git-commits.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---

convention:
commitTypes:
- feat
- fix
- perf
- refactor
- style
- test
- build
- ops
- docs
- merge
commitScopes: []
releaseTagGlobPattern: v[0-9]*.[0-9]*.[0-9]*

changelog:
commitTypes:
- feat
- fix
- perf
- merge
includeInvalidCommits: true
commitScopes: []
commitIgnoreRegexPattern: "^WIP "
headlines:
feat: Features
fix: Bug Fixes
perf: Performance Improvements
merge: Merges
breakingChange: BREAKING CHANGES
commitUrl: https://github.com/klen/muffin-grpc/commit/%commit%
commitRangeUrl: https://github.com/klen/muffin-grpc/compare/%from%...%to%?diff=split
issueRegexPattern: "#[0-9]+"
issueUrl: https://github.com/klen/muffin-grpc/issues/%issue%
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@main
Expand Down
100 changes: 68 additions & 32 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,48 +1,84 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks

fail_fast: true
default_install_hook_types: [commit-msg, pre-commit, pre-push]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-merge-conflict
- id: check-case-conflict
- id: check-toml
- id: check-ast
- id: debug-statements

- repo: https://github.com/qoomon/git-conventional-commits
rev: 'v2.6.5'
hooks:
- id: conventional-commits
args: ["-c", ".git-commits.yaml"]
stages: ["commit-msg"]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-case-conflict
stages: ["pre-commit"]
- id: check-merge-conflict
stages: ["pre-commit"]
- id: check-added-large-files
stages: ["pre-commit"]
- id: check-ast
stages: ["pre-commit"]
- id: check-executables-have-shebangs
stages: ["pre-commit"]
- id: check-symlinks
stages: ["pre-commit"]
- id: check-toml
stages: ["pre-commit"]
- id: check-yaml
stages: ["pre-commit"]
- id: debug-statements
stages: ["pre-commit"]
- id: end-of-file-fixer
stages: ["pre-commit"]
- id: trailing-whitespace
stages: ["pre-commit"]

- repo: https://github.com/psf/black
rev: 23.1.0
rev: 23.7.0
hooks:
- id: black
stages: ["pre-commit"]

- repo: https://github.com/python-poetry/poetry
rev: '1.4.0'
rev: '1.5.0'
hooks:
- id: poetry-check
- id: poetry-lock
args: ["--no-update"]
- id: poetry-check
files: ^(.*/)?pyproject\.toml$
stages: ["pre-commit"]
- id: poetry-lock
files: ^(.*/)?(poetry\.lock|pyproject\.toml)$
args: ["--no-update"]
stages: ["pre-commit"]

- repo: local
hooks:
- id: ruff
name: ruff
entry: poetry run ruff check muffin_grpc
language: system
pass_filenames: false
files: \.py$
stages: ["pre-commit"]

- id: mypy
name: mypy
entry: poetry run mypy
language: system
pass_filenames: false
files: \.py$
stages: ["pre-push"]

- id: pytest
name: pytest
entry: poetry run pytest
language: system
pass_filenames: false
files: \.py$
stages: ["pre-push"]

- id: mypy
name: mypy
entry: poetry run mypy
language: system
pass_filenames: false

- id: ruff
name: ruff
entry: poetry run ruff muffin_grpc
language: system
pass_filenames: false

- id: pytest
name: pytest
entry: poetry run pytest tests
language: system
pass_filenames: false
26 changes: 13 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ VIRTUAL_ENV ?= .venv
# Development
# =============

$(VIRTUAL_ENV): poetry.lock
$(VIRTUAL_ENV): poetry.lock .pre-commit-config.yaml
@[ -d $(VIRTUAL_ENV) ] || python -m venv $(VIRTUAL_ENV)
@poetry install --with tests,dev
@poetry run pre-commit install --hook-type pre-push
@poetry run pre-commit install
@poetry self add poetry-bumpversion
@touch $(VIRTUAL_ENV)

.PHONY: test t
Expand Down Expand Up @@ -39,18 +40,17 @@ build: $(VIRTUAL_ENV) clean
VPART ?= minor
# target: release - Bump version
release: $(VIRTUAL_ENV)
@git checkout develop
@git pull
@git checkout master
@git pull
@git merge develop
git checkout develop
git pull
git checkout master
git merge develop
git pull
@poetry version $(VPART)
@git commit -am "Bump version: `poetry version -s`"
@git tag `poetry version -s`
@git checkout develop
@git merge master
@git push origin develop master
@git push --tags
git commit -am "build(release): `poetry version -s`"
git tag `poetry version -s`
git checkout develop
git merge master
git push --tags origin develop master

.PHONY: minor
minor: release
Expand Down
14 changes: 7 additions & 7 deletions muffin_grpc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from importlib import import_module
from pathlib import Path
from signal import SIGINT, SIGTERM
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union
from typing import TYPE_CHECKING, Any, Optional, Union

import grpc
from grpc_tools import protoc
Expand Down Expand Up @@ -44,8 +44,8 @@ class Plugin(BasePlugin):
def __init__(self, *args, **kwargs):
"""Initialize the plugin."""
super(Plugin, self).__init__(*args, **kwargs)
self.proto_files: List[
Tuple[Union[str, Path], Optional[Union[str, Path]], Dict[str, Any]]
self.proto_files: list[
tuple[Union[str, Path], Optional[Union[str, Path]], dict[str, Any]]
] = []
self.services = []
self.channel = None
Expand Down Expand Up @@ -140,14 +140,14 @@ def get_channel(self, address: Optional[str] = None, **options):
**(options or self.cfg.default_channel_options),
)

def build_proto( # noqa: PLR0913
def build_proto(
self,
path: Union[str, Path],
build_dir: Optional[Union[str, Path]] = None,
build_package: Optional[Union[str, bool]] = None,
targets: Optional[List[Path]] = None,
include: Optional[List[Path]] = None,
) -> List[Path]:
targets: Optional[list[Path]] = None,
include: Optional[list[Path]] = None,
) -> list[Path]:
"""Build the given proto."""
path = Path(path)
if not path.exists():
Expand Down
Loading

0 comments on commit 31e0783

Please sign in to comment.