Skip to content

Commit

Permalink
ci/cd: update pre-commit hooks and dependencies except pydantic
Browse files Browse the repository at this point in the history
  • Loading branch information
oedokumaci committed Feb 21, 2024
1 parent 8e14b87 commit 1165445
Show file tree
Hide file tree
Showing 10 changed files with 425 additions and 516 deletions.
57 changes: 38 additions & 19 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
repos:
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 24.2.0
hooks:
- id: black

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 7.0.0
hooks:
- id: flake8
args:
Expand All @@ -16,15 +16,15 @@ repos:
- flake8-bugbear

- repo: https://github.com/PyCQA/isort
rev: 5.12.0 # need 5.12.0 to fix RuntimeError: The Poetry configuration is invalid
rev: 5.13.2 # need 5.12.0 to fix RuntimeError: The Poetry configuration is invalid
hooks:
- id: isort
args:
- --multi-line=3
- --profile=black # to be compatible with black

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: end-of-file-fixer
- id: check-yaml
Expand All @@ -33,14 +33,46 @@ repos:
- id: requirements-txt-fixer

- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
rev: v2.2.6
hooks:
- id: codespell
exclude: ^config/

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.2
rev: v3.15.1
hooks:
- id: pyupgrade
args: [--py310-plus]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
args:
- src
- tests
pass_filenames: false
additional_dependencies:
- pydantic==1.10.8
- pytest
- rich
- typer
- types-PyYAML

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.7.1
hooks:
- id: nbqa-black
# additional_dependencies: [jupytext] # optional, only if you're using Jupytext
- id: nbqa-pyupgrade
args: [--py310-plus]
- id: nbqa-isort
args: [--float-to-top, --profile=black]

- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
hooks:
- id: nbstripout

- repo: local
hooks:
Expand All @@ -59,19 +91,6 @@ repos:
entry: pdm lock --check
language: system
pass_filenames: false
- id: mypy
name: mypy
entry: |
bash -c "
if git diff --name-only --cached --diff-filter=ACM | grep -q '\.py$'; then
pdm run mypy $(git diff --name-only --cached --diff-filter=ACM | grep '\.py$');
elif git diff --name-only --cached --diff-filter=ACM | grep -q . ; then
echo 'No staged .py files, skipping...';
else
find src -name '*.py' -exec pdm run mypy {} +;
fi"
language: system
pass_filenames: false
- id: pytest-check
name: pytest-check
entry: pdm run pytest
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: help vscode-settings setup update-dev update-user run project-help test pre-commit clean
.PHONY: help vscode-settings setup update-dev update-user run docker-build docker-run docker docker-logs docker-stop docker-kill project-help test pre-commit clean

help: ## Show this help message for each Makefile recipe
ifeq ($(OS),Windows_NT)
Expand All @@ -12,7 +12,7 @@ setup: ## Setup project
pdm run pre-commit install

update-dev: ## Update project dependencies for development
pdm update
pdm update --skip pydantic
pdm run pre-commit autoupdate
make test

Expand Down
843 changes: 367 additions & 476 deletions pdm.lock

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = [
dependencies = [
"pdm>=2.5.3",
"pyyaml>=6.0",
"pydantic>=1.10.5",
"pydantic==1.10.8",
"typer>=0.7.0",
]
requires-python = ">=3.9"
Expand All @@ -19,8 +19,6 @@ license = {text = "MIT"}
[tool.pdm.dev-dependencies]
workflow = [
"pre-commit>=3.0.4",
"mypy>=1.2.0",
"types-PyYAML>=6.0.12.9",
]
test = [
"pytest>=7.2.1",
Expand Down
4 changes: 1 addition & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# This file is @generated by PDM.
# Please do not edit it manually.

mypy>=1.2.0
pdm>=2.5.3
pre-commit>=3.0.4
pydantic>=1.10.5
pydantic==1.10.8
pytest>=7.2.1
pyyaml>=6.0
typer>=0.7.0
types-PyYAML>=6.0.12.9
12 changes: 7 additions & 5 deletions src/gale_shapley/algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ def print_all_preferences(self, compact: bool = True) -> None:
for i in range(len(first_column)):
data.append(
[
person.preferences[i].name
if bool(person.preferences)
and i < len(person.preferences)
and person.is_acceptable(person.preferences[i])
else ""
(
person.preferences[i].name
if bool(person.preferences)
and i < len(person.preferences)
and person.is_acceptable(person.preferences[i])
else ""
)
for person in self.persons
]
)
Expand Down
6 changes: 3 additions & 3 deletions src/gale_shapley/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class YAMLConfig(BaseModel):
number_of_proposers: int
number_of_responders: int
log_file_name: str
proposers: dict[
str, list[str]
] = {} # mutable default values are fine, pydantic takes care of it
proposers: dict[str, list[str]] = (
{}
) # mutable default values are fine, pydantic takes care of it
responders: dict[str, list[str]] = {}

@validator("proposer_side_name", "responder_side_name")
Expand Down
6 changes: 3 additions & 3 deletions src/gale_shapley/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ def blocking_pairs(self) -> list[tuple[Proposer, Responder]]:
blocking: list[tuple[Proposer, Responder]] = []
for proposer in self.proposers: # looping one side is enough
if bool(proposer.preferences) and proposer.is_matched:
better_than_match_of_proposer: tuple[
Proposer | Responder, ...
] = proposer.preferences[: proposer.preferences.index(proposer.match)]
better_than_match_of_proposer: tuple[Proposer | Responder, ...] = (
proposer.preferences[: proposer.preferences.index(proposer.match)]
)
for responder in better_than_match_of_proposer:
if isinstance(
responder, Responder
Expand Down
3 changes: 2 additions & 1 deletion src/gale_shapley/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""Module for utility functions."""

import logging
from collections.abc import Callable
from pathlib import Path
from time import time
from typing import Callable, TypeVar
from typing import TypeVar

from rich.logging import RichHandler
from typing_extensions import (
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
import random
from typing import Generator
from collections.abc import Generator

import pytest

Expand Down

0 comments on commit 1165445

Please sign in to comment.