Skip to content

Commit

Permalink
Replace poetry with uv
Browse files Browse the repository at this point in the history
  • Loading branch information
danhje committed Dec 4, 2024
1 parent 49cbfa3 commit dd4900e
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 138 deletions.
8 changes: 0 additions & 8 deletions .flake8

This file was deleted.

16 changes: 11 additions & 5 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ on:
release:
types: [created]
jobs:
build:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build and publish to pypi
uses: JRubics/[email protected]

- name: Install uv
uses: astral-sh/setup-uv@v4
with:
pypi_token: ${{ secrets.PYPI_TOKEN }}
version: "0.5.6"

- name: Build and publish to pypi
run: |
uv build
uv publish
31 changes: 16 additions & 15 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,24 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v4
with:
python-version: ${{ matrix.python-version }}
version: "0.5.6"

- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade poetry
poetry install
- name: Lint with flake8
run: |
poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
run: uv sync --all-extras --dev

- name: Lint with ruff
run: uv run ruff check

- name: Test with pytest
run: |
poetry run pytest
run: uv run pytest tests
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,5 @@ local.dockerfile # only for local pycharm use
# pyenv
.python-version

# Poetry
poetry.lock
# uv
uv.lock
28 changes: 6 additions & 22 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,18 @@ default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: check-json
- id: check-merge-conflict
- id: debug-statements
- id: detect-private-key
- id: check-yaml
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/hadialqattan/pycln
rev: v2.1.3
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.1
hooks:
- id: pycln
args: [--all]
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
additional_dependencies: [toml]
- repo: https://github.com/Lucas-C/pre-commit-hooks-bandit
rev: v1.0.6
hooks:
- id: python-bandit-vulnerability-check
args: [-ll, -ii, --exclude, ./.venv/*, --recursive, .]
pass_filenames: false
always_run: true
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
151 changes: 85 additions & 66 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,76 +1,96 @@
[tool.poetry]
[project]
name = "wgt"
version = "0.2.0"
dynamic = ["version"]
description = "Command line tool for quick API testing"
authors = ["Daniel Hjertholm <daniel.hjertholm@icloud.com>"]

[tool.poetry.dependencies]
python = "^3.9"
requests = "*"
toolz = "*"
rich = "*"
authors = [{name="Daniel Hjertholm", email="[email protected].com"}]
requires-python = ">=3.9"
dependencies = [
"requests",
"toolz",
"rich",
]

[tool.poetry.dev-dependencies]
black = "*"
coverage = { version = "*", extras = ['toml'] }
flake8 = "*"
flake8-bugbear = "*"
isort = ">= 5"
mock = "*"
pre-commit = "*"
pytest = ">= 6"
pytest-cov = "*"
pytest-integration = "*"
pytest-randomly = "*"
[tool.uv]
dev-dependencies = [
"pytest",
"pytest-randomly",
"ruff",
"pre-commit",
]

[tool.poetry.scripts]
[project.scripts]
wgt = "wgt.wgt:main"

[tool.poetry-dynamic-versioning]
enable = true
vcs = "git"
style = "semver"
pattern = "^(?P<base>\\d+\\.\\d+\\.\\d+)(-?((?P<stage>[a-zA-Z]+)\\.?(?P<revision>\\d+)?))?$"
[tool.setuptools_scm]
version_scheme="release-branch-semver"
local_scheme = "no-local-version"

[tool.ruff]
target-version = "py39"

line-length = 120

[tool.isort]
profile = "black"
line_length = 100
known_first_party = []
[tool.ruff.lint]

[tool.black]
line-length = 100
include = '\.pyi?$'
exclude = '''
/(
\.git
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
| profiling
)/
'''
select = [
"A", # flake8-builtins
"ANN", # flake8-annotations
"ARG", # flake8-unused-arguments
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"C90", # mccabe
"COM", # flake8-commas
"DTZ", # flake8-datetimez
"E", "W", # pycodestyle
"F", # Pyflakes
"G", # flake8-logging-format
"I", # isort
"LOG", # flake8-logging
"N", # pep8-nameing
"PIE", # flake8-pie
"RUF", # Ruff specific rules
"S", # flake8-bandit
"SIM", # flake8-simplify
"T20", # flake8-print
"T100", # debug statements
"TCH", # flake8-type-checking
"UP", # pyupgrade
"YTT", # flake8-2020
]

ignore = ['ANN002', 'ANN003', 'S101', 'COM812', 'ANN401', 'T201']

[tool.coverage.report]
# Regexes for lines to exclude from consideration
exclude_lines = [
"pragma: no cover",
"raise AssertionError",
"raise NotImplementedError",
"if verbose:",
"if 0:",
"if False:",
]
skip_covered = true
show_missing = true
precision = 2
# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"]
unfixable = []

[tool.coverage.run]
branch = true
source = ["wgt"]
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
]

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[tool.pytest.ini_options]
log_file = "pytest.log"
Expand All @@ -85,7 +105,6 @@ filterwarnings = [
"ignore:PyArray_SetNumericOps.*",
]


[build-system]
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"]
build-backend = "poetry.core.masonry.api"
requires = ["setuptools>=64", "setuptools-scm>=8"]
build-backend = "setuptools.build_meta"
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os


def pytest_configure():
def pytest_configure() -> None:
os.environ["WGT_DEFAULT_PROTOCOL"] = "https://"
os.environ["WGT_DEFAULT_HOST"] = "127.0.0.1"
os.environ["WGT_DEFAULT_PORT"] = ":8080"
Expand Down
Loading

0 comments on commit dd4900e

Please sign in to comment.