Skip to content

Commit

Permalink
Migrate to poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasborgen committed Jan 24, 2025
1 parent a815c6e commit ec68bc2
Show file tree
Hide file tree
Showing 8 changed files with 1,787 additions and 158 deletions.
65 changes: 30 additions & 35 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,39 @@ name: test

on: [push]

name: Test Backend

on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize

jobs:
build:
test-backend:
runs-on: ubuntu-latest
strategy:
max-parallel: 2
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']

python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

- name: Create gcloud key file
run: openssl base64 -d -A <<< '${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY }}' -out key.json

- name: Install poetry
run: |
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python -
- name: Set up cache
uses: actions/cache@v1
with:
path: .venv
key: venv-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
run: |
poetry config virtualenvs.in-project true
poetry install
- name: Run tests
run: |
poetry run poetry check
poetry run pip check
poetry run flake8 .
poetry run pytest .
poetry run safety check --full-report
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.4.15"
enable-cache: true
- name: Run tests
run: uv run pytest
run: |
uv run ruff --check
uv run pytest .
uv run safety check --full-report
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,22 @@

## Latest Changes



## 4.0.0

### Breaking

* Drop support for python 3.6 - 3.8

### Feature

* Add py.typed file to mark that this library is typed.

### Internal

* Run CI for python 3.10
* Run CI for python 3.9, 3.10, 3.11, 3.12
* Use `uv` instead of `poetry`

## 3.0.0

Expand Down
4 changes: 2 additions & 2 deletions docs/contrib/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

## Submitting your code

1. We use protected `master` branch, so the only way to push code is via [pull-request](http://oss-watch.ac.uk/resources/pullrequest)
1. We use protected `main` branch, so the only way to push code is via [pull-request](http://oss-watch.ac.uk/resources/pullrequest)
2. To implement new issue, you need to create either fix/name-of-the-bug or feature/name-of-the-feature
3. One of the commits should say Close #ISSUE_NUMBER, so pull-request will be associated with certain issue
4. Branch should be rebased on top of latest `master` branch
4. Branch should be rebased on top of latest `main` branch
5. You can mark branch as `[WIP]` until it is finished and all checks are passed
6. When all the above steps succeeded mention one of the mainters and ask for the review

Expand Down
46 changes: 46 additions & 0 deletions poetry_pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[tool.poetry]
name = "storage-bucket"
version = "3.0.0"
description = "Easy to work with Google Cloud Platform Storage Bucket wrapper"
authors = ["Thomas Borgen <thomas@borgenit.no>", "Dmytro Chasovskyi <dmitriy.chasovskoy@gmail.com>"]

license = "MIT"
readme = "docs/index.md"
repository = "https://github.com/thomasborgen/storage-bucket"
documentation = "https://thomasborgen.github.io/storage-bucket"

keywords = [
"Storage Bucket",
"GCP",
"Google Cloud Platform",
"monad",
"functional programming"
]

classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Utilities"
]

[tool.poetry.dependencies]
python = "^3.6"
google-cloud-storage = "^1.42.3"

[tool.poetry.dev-dependencies]
wemake-python-styleguide = "^0.15.3"
mypy = "^0.910"
isort = "^4.3.21"

safety = "^1.10.3"

pytest = "^6.2.5"
pytest-cov = "^3.0.0"
pytest-env = "^0.6.2"
mkdocs-material = "^7.3.4"

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
143 changes: 118 additions & 25 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[tool.poetry]
[project]
name = "storage-bucket"
version = "3.0.0"
description = "Easy to work with Google Cloud Platform Storage Bucket wrapper"
authors = ["Thomas Borgen <thomas@borgenit.no>", "Dmytro Chasovskyi <dmitriy.chasovskoy@gmail.com>"]

readme = "docs/index.md"
license = "MIT"
readme = "docs/index.md"
repository = "https://github.com/thomasborgen/storage-bucket"
Expand All @@ -13,34 +13,127 @@ keywords = [
"Storage Bucket",
"GCP",
"Google Cloud Platform",
"monad",
"functional programming"
"GCP Storage Bucket",
]

classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Utilities"
requires-python = ">=3.9"
dependencies = [
"google-cloud-storage>=2.19.0",
]

[tool.poetry.dependencies]
python = "^3.6"
google-cloud-storage = "^1.42.3"
[dependency-groups]
dev = [
"mypy>=1.14.1",
"pytest-cov>=6.0.0",
"pytest>=8.3.4",
"pytest-env>=1.1.5",
"mkdocs-material>=9.5.50",
"ruff>=0.9.3",
"safety>=3.2.14",
]

[tool.poetry.dev-dependencies]
wemake-python-styleguide = "^0.15.3"
mypy = "^0.910"
isort = "^4.3.21"

safety = "^1.10.3"
[tool.ruff]
line-length = 79
indent-width = 4
target-version = "py311"

pytest = "^6.2.5"
pytest-cov = "^3.0.0"
pytest-env = "^0.6.2"
mkdocs-material = "^7.3.4"
[tool.ruff.lint]
exclude = [
".git",
".venv",
"__pycache__",
"alembic/*",
]
select = [
# Regular flake8 rules
"C", "E", "F", "W", "S",
# flake8-bugbear rules
"B",
# extra flake rules
"YTT",
# Import sorting rules (isort replacement)
"I",
# Pylint rules
"PLC", "PLE", "PLR", "PLW",
# ruff rules
"RUF",
# Docstyle
"D",
# Max camplexity
"C90",
]

ignore = [
"D100", # Docstring in modules
"D203", # Incompatible with D211
"D213", # Incompatible with D212
# FastApi uses a lot of dependency injection and performs calls/object inits
# in argument defaults.
"B008",
]

fixable = ["ALL"]

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["D104"]
"**/{tests}/*" = [
"D103", # Allow missing docstring in functions
"S101", # Allow asserts
"S106", # Allow hardcorded passwords in tests
]
"**/conftest.py" = [
"F811", # Allow redefinition (imported fixtures)
]
"**/utils.py" = [
"PLR0913", # Allow too many return statements
]
"warp/tags/**" = [
"D101", # Allow missing docstring
]

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
[tool.ruff.lint.mccabe]
# Flag errors (`C901`) whenever the complexity level exceeds 6.
max-complexity = 6

[tool.ruff.lint.pylint]
max-public-methods = 8

[tool.ruff.format]
quote-style = "double"

[tool.ruff.flake8-tidy-imports]
ban-relative-imports = "parents"

[tool.ruff.isort]
combine-as-imports = true

[tool.mypy]
plugins = [
"pydantic.mypy",
]

# follow_imports = "silent"
warn_redundant_casts = true
warn_unused_ignores = true
disallow_any_generics = true
check_untyped_defs = true
no_implicit_reexport = true

# for strict mypy: (this is the tricky one :-))
disallow_untyped_defs = true

[tool.pydantic-mypy]
init_forbid_extra = true
init_typed = true
warn_required_dynamic_aliases = true

[tool.pytest.ini_options]
# py.test options:
norecursedirs = ["*.egg", ".eggs", "dist", "build", "docs", ".tox", ".git", "__pycache__"]
testpaths = [
"tests",
]
env = [
"GOOGLE_APPLICATION_CREDENTIALS=key.json",
]
Loading

0 comments on commit ec68bc2

Please sign in to comment.