Skip to content

Commit

Permalink
[GH-40] Update package versions and tooling (#41)
Browse files Browse the repository at this point in the history
* [GH-40] chore: update package versions in pre-commit and pyproject

* [GH-40] chore: update rest of packages

* [GH-40] chore: lint

* [GH-40] chore: update psycop

* [GH-40] chore: update top level pacakges

* [GH-40] chore: update lock file

* [GH-40] chore: allow MacOS tests
  • Loading branch information
nickatnight authored Oct 29, 2023
1 parent ba3d0c7 commit 7db8497
Show file tree
Hide file tree
Showing 10 changed files with 441 additions and 362 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
- name: Install poetry 📚
run: pipx install poetry

- name: Set up Python 3.9 🐍
- name: Set up Python ${{ env.PYTHON_VERSION }} 🐍
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
Expand Down
11 changes: 6 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,27 @@ default_language_version:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: debug-statements
- id: requirements-txt-fixer
# - id: pretty-format-json
- repo: https://github.com/psf/black
rev: 22.6.0
rev: 23.10.1
hooks:
- id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.241'
rev: 'v0.1.3'
hooks:
- id: ruff
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
rev: v2.2.5
hooks:
- id: codespell
703 changes: 390 additions & 313 deletions poetry.lock

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ repository = "https://github.com/nickatnight/cookiecutter-fastapi-backend"
python = "^3.9"

[tool.poetry.group.dev.dependencies]
cookiecutter = "^2.1.1"
pytest = "^7.2.1"
pytest-cookies = "0.6.1"
sh = "^2.0.2"
binaryornot = "^0.4.4"
pre-commit = "^3.0.4"
pytest-instafail = "^0.4.2"
cookiecutter = "2.4.0"
pytest = "7.4.3"
pytest-cookies = "0.7.0"
sh = "2.0.6"
binaryornot = "0.4.4"
pre-commit = "3.5.0"
pytest-instafail = "0.5.0"

[tool.ruff]
line-length = 100
Expand Down
6 changes: 3 additions & 3 deletions tests/test_bake_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

if sys.platform.startswith("win"):
pytest.skip("sh doesn't support windows", allow_module_level=True)
elif sys.platform.startswith("darwin") and os.getenv("CI"):
# "CI" env var is provided by GHA runner
pytest.skip("skipping slow macOS tests on CI", allow_module_level=True)
# elif sys.platform.startswith("darwin") and os.getenv("CI"):
# # "CI" env var is provided by GHA runner
# pytest.skip("skipping slow macOS tests on CI", allow_module_level=True)

SUPPORTED_COMBINATIONS = [
{"include_example_api": "no"},
Expand Down
13 changes: 7 additions & 6 deletions {{ cookiecutter.project_slug }}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@ default_language_version:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: debug-statements
- id: requirements-txt-fixer
- id: pretty-format-json
- repo: https://github.com/psf/black
rev: 22.6.0
rev: 23.10.1
hooks:
- id: black
args: ["--config=./{{ cookiecutter.backend_container_name }}/pyproject.toml"]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.241'
rev: 'v0.1.3'
hooks:
- id: ruff
- repo: https://github.com/PyCQA/isort
Expand All @@ -25,11 +26,11 @@ repos:
- id: isort
args: ["--settings-path=./{{ cookiecutter.backend_container_name }}/pyproject.toml"]
- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
rev: v2.2.5
hooks:
- id: codespell
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v0.982
# rev: v1.6.1
# hooks:
# - id: mypy
# args: ["--config-file=./{{ cookiecutter.backend_container_name }}/pyproject.toml"]
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@ authors = ["nickatnight <[email protected]>"]

[tool.poetry.dependencies]
python = "~{{ cookiecutter.py_version }}"
alembic = "^1.8.1"
asyncpg = "^0.26.0"
fastapi = "^0.92.0"
psycopg2-binary = "^2.9.3"
sqlmodel = "^0.0.8"
uvicorn = {extras = ["standard"], version = "^0.20.0"}
redis = "^4.5.1"
fastapi-cache2 = {extras = ["redis"], version = "^0.1.9"}
PyYAML = "^6.0"
httpx = "^0.23.3"
gunicorn = "^20.1.0"
alembic = "1.12.1"
asyncpg = "0.28.0"
fastapi = "0.104.0"
psycopg2-binary = "2.9.9"
sqlmodel = "0.0.10"
uvicorn = {extras = ["standard"], version = "0.23.2"}
redis = "4.6.0"
fastapi-cache2 = {extras = ["redis"], version = "0.2.1"}
PyYAML = "6.0.1"
httpx = "0.25.0"
gunicorn = "21.0.1"

[tool.poetry.dev-dependencies]
black = "^22.6.0"
isort = "^5.12.0"
mock = "^4.0.3"
pytest = "^7.2.1"
pytest-cov = "^4.0.0"
pytest-mock = "^3.10.0"
pytest-asyncio = "^0.19.0"
mypy = "^0.982"
ruff = "^0.0.241"
requests = "^2.28.2"
black = "23.10.1"
isort = "5.12.0"
pytest = "7.4.3"
pytest-cov = "4.1.0"
pytest-mock = "3.12.0"
pytest-asyncio = "0.21.1"
mypy = "1.6.1"
ruff = "0.1.3"
requests = "2.31.0"
sqlalchemy-stubs = "0.4"

[tool.isort]
multi_line_output = 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ async def memes(
skip=skip, limit=limit, sort_field=sort_field, sort_order=sort_order
)

return IGetResponseBase[List[IMemeRead]](data=memes)
return IGetResponseBase[List[IMemeRead]](data=memes) # type: ignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ class Settings(BaseSettings):
POSTGRES_HOST: str = Field(default="", env="POSTGRES_HOST")
POSTGRES_PORT: str = Field(default="", env="POSTGRES_PORT")
POSTGRES_DB: str = Field(default="", env="POSTGRES_DB")
POSTGRES_URL: Optional[str] = None

REDIS_HOST: str = Field(default="", env="REDIS_HOST")
REDIS_PORT: str = Field(default="", env="REDIS_PORT")

DB_POOL_SIZE: int = Field(default=83, env="DB_POOL_SIZE")
WEB_CONCURRENCY: int = Field(default=9, env="WEB_CONCURRENCY")
MAX_OVERFLOW: int = Field(default=64, env="MAX_OVERFLOW")
POOL_SIZE: Optional[int]
POSTGRES_URL: Optional[str]
POOL_SIZE: Optional[int] = None

@validator("POOL_SIZE", pre=True)
def build_pool(cls, v: Optional[str], values: Dict[str, Any]) -> Any:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async def create(self, obj_in: CreateSchemaType, **kwargs: Any) -> ModelType:
async def get(self, **kwargs: Any) -> Optional[ModelType]:
logger.info(f"Fetching [{self._model.__class__.__name__}] object by [{kwargs}]")

query = select(self._model).filter_by(**kwargs)
query = select(self._model).filter_by(**kwargs) # type: ignore
response = await self.db.execute(query)
scalar: Optional[ModelType] = response.scalar_one_or_none()

Expand Down Expand Up @@ -97,12 +97,12 @@ async def all(
query = select(self._model).offset(skip).limit(limit).order_by(order_by)

response = await self.db.execute(query)
return response.scalars().all()
return response.scalars().all() # type: ignore

async def f(self, **kwargs: Any) -> List[ModelType]:
logger.info(f"Fetching [{self._model.__class__.__name__}] object by [{kwargs}]")

query = select(self._model).filter_by(**kwargs)
query = select(self._model).filter_by(**kwargs) # type: ignore
response = await self.db.execute(query)
scalars: List[ModelType] = response.scalars().all()

Expand Down

0 comments on commit 7db8497

Please sign in to comment.