Skip to content

Commit

Permalink
Update to new setup
Browse files Browse the repository at this point in the history
uv, ruff, just et al.
  • Loading branch information
nkantar committed Aug 25, 2024
1 parent f82f576 commit 2e05926
Show file tree
Hide file tree
Showing 21 changed files with 893 additions and 227 deletions.
60 changes: 30 additions & 30 deletions .github/workflows/code-quality-checks.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Code quality checks
name: Automated Checks

on:
push:
Expand All @@ -7,49 +7,49 @@ on:
pull_request:

jobs:
code_quality:
name: Check code quality

check:
runs-on: ubuntu-latest

continue-on-error: true
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"] # TODO 3.8 won't work
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13-dev"]

steps:
- name: Checkout repository
uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: sh bin/cicd_install.sh
- name: Install just
# Temporarily use the open PR branch:
# - https://github.com/casey/just/pull/2312
# - https://github.com/casey/just/issues/2311
run: pipx install git+https://github.com/rachtsingh/just.git

- name: Check code formatting
run: make formatcheck
- name: Install uv
run: pipx install uv

- name: Check for linter errors
run: make lint
- name: Install dependencies
run: uv sync

- name: Check docstring formatting
run: make doccheck
- name: Check formatting via ruff
run: uv run just formatcheck

- name: Check doc site build
run: make docs
- name: Check docstring formatting via pydocstyle
run: uv run just docstylecheck

- name: Check type annotations
run: make typecheck
- name: Check type hints via mypy
run: uv run just typecheck

- name: Run tests
run: make test
- name: Run linter via ruff
run: uv run just lint

- name: Check code coverage
run: make covcheck
- name: Run tests via pytest
run: uv run just test

- name: Check build
run: poetry build
- name: Build docs via sphinx
run: uv run just docs
54 changes: 0 additions & 54 deletions .github/workflows/pypi-publish.yml

This file was deleted.

15 changes: 0 additions & 15 deletions bin/cd_validate_build.sh

This file was deleted.

9 changes: 0 additions & 9 deletions bin/cicd_install.sh

This file was deleted.

5 changes: 4 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"""Sphinx configuration."""

import os
import sys
from typing import Any


# Configuration file for the Sphinx documentation builder.
Expand Down Expand Up @@ -44,7 +47,7 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []
exclude_patterns: list[Any] = []


# -- Options for HTML output -------------------------------------------------
Expand Down
39 changes: 39 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
############################################################
# All commands are to be run inside a virtual environment. #
# E.g., #
# uv run just lint #
############################################################


# check formatting via ruff
formatcheck:
ruff format --check .

# check docstring formatting via pydocstyle
docstylecheck:
pydocstyle .

# check type hints via mypy
typecheck:
mypy --strict .

# run linter via ruff
lint:
ruff check .

# run tests via pytest and coverage
test:
pytest --cov=. --cov-fail-under=100 -svv

# build docs via sphinx
docs:
make -C docs html

# run all checks
checkall:
just formatcheck
just docstylecheck
just typecheck
just lint
just test
just docs
9 changes: 0 additions & 9 deletions parsenvy/__init__.py

This file was deleted.

90 changes: 25 additions & 65 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
[tool.poetry]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "Parsenvy"
version = "3.0.2"
dependencies = []
requires-python = ">=3.9"
authors = [
{name = "Nik Kantar", email = "[email protected]" },
]
description = "Enviously elegant environment variable parsing"
license = "BSD-3-Clause"
authors = ["Nik Kantar <[email protected]>"]
readme = "README.rst"
homepage = "https://pypi.org/project/Parsenvy"
repository = "https://github.com/nkantar/Parsenvy"
documentation = "https://parsenvy.readthedocs.io"

keywords = ["environment", "variables"]
license = {file = "LICENSE"}
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand All @@ -24,68 +26,26 @@ classifiers = [
"Typing :: Typed",
]

include = [
"CHANGELOG.md",
"CODE_OF_CONDUCT.rst",
"CONTRIBUTING.rst",
"LICENSE",
"Makefile",
"README.rst",
"bin/*.sh",
"docs/Makefile",
"docs/make.bat",
"docs/source/*.rst",
"docs/source/conf.py",
"parsenvy/*.py",
"poetry.lock",
"pyproject.toml",
"tests/test_*.py",
]

[tool.poetry.dependencies]
python = "^3.9" # TODO not ideal, supporting 3.8 would be good

# Docs
sphinx = {version = "^7.2.6", optional = true}
sphinx-rtd-theme = {version = "^2.0.0", optional = true}
sphinx-mdinclude = {version = "^0.5.3", optional = true}

[tool.poetry.dev-dependencies]
mypy = "^1.8.0"
black = "^23.12.1"
flake8 = "^6.1.0"
pydocstyle = "^6.3.0"
pytest = "^7.4.4"
pytest-watch = "^4.2.0"
coverage = "^7.4.0"
pytest-cov = "^4.1.0"
pdbpp = "^0.10.3"
sphinx-mdinclude = "^0.5.3"

# Docs
# NOTE: Please also add to:
# - [tool.poetry.dependencies] above as optional
# - [tool.poetry.extras] below
sphinx = "^7.2.6"
sphinx-rtd-theme = "^2.0.0"

[tool.poetry.extras]
docs = [
"sphinx",
"sphinx-rtd-theme",
"sphinx-mdinclude",
[tool.uv]
dev-dependencies = [
"ruff>=0.6.2",
"pytest>=8.3.2",
"pydocstyle>=6.3.0",
"mypy>=1.11.2",
"pdbpp>=0.10.3",
"coverage>=7.6.1",
"sphinx>=7.4.7",
"sphinx-rtd-theme>=2.0.0",
"sphinx-mdinclude>=0.6.2",
"pytest-cov>=5.0.0",
]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.pytest]
python_paths = "parsenvy"
python_paths = "src/parsenvy"

[tool.coverage.run]
branch = true
source = ["parsenvy"]
source = ["src"]

[tool.coverage.report]
show_missing = true
5 changes: 5 additions & 0 deletions src/parsenvy/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""Main Parsenvy module."""

from parsenvy.parsenvy import bool, float, int, list, set, str, tuple

__all__ = ["bool", "float", "int", "list", "set", "str", "tuple"]
1 change: 0 additions & 1 deletion parsenvy/parsenvy.py → src/parsenvy/parsenvy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
user is meant to utilize.
"""


import builtins
from functools import wraps
import os
Expand Down
Empty file added src/parsenvy/py.typed
Empty file.
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Tests for all of Parsenvy."""
Loading

0 comments on commit 2e05926

Please sign in to comment.