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 9063207 commit 1c5837f
Show file tree
Hide file tree
Showing 14 changed files with 511 additions and 83 deletions.
2 changes: 0 additions & 2 deletions .flake8

This file was deleted.

54 changes: 28 additions & 26 deletions .github/workflows/automated_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,43 @@ on:
pull_request:

jobs:
automated_checks:
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.7", "3.8", "3.9", "3.10"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

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

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

- 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: Install uv
run: pipx install uv

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry config virtualenvs.create false
poetry install --no-root --no-interaction
- name: Check formatting via ruff
run: uv run just formatcheck

- name: Run tests
run: pytest
- name: Check type hints via mypy
run: uv run just typecheck

- name: Run type checker
run: mypy --strict mdut
- name: Run linter via ruff
run: uv run just lint

- name: Run linter
run: flake8
- name: Run tests via pytest
run: uv run just test

- name: Check build
run: poetry build
19 changes: 12 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@


<!--
headers:
Added - new features
Changed - changes in existing functionality
Deprecated - soon-to-be removed features
Removed - now removed features
Fixed - any bug fixes
Security - in case of vulnerabilities
- Added: for new features
- Changed: for changes in existing functionality
- Deprecated: for soon-to-be removed features
- Removed: for now removed features
- Fixed: for any bug fixes
- Security: in case of vulnerabilities
-->


## [Unreleased]

### Added
- Python 3.11, and 3.12 to CI version matrix

### Removed
- Python 3.7 and 3.8 from CI version matrix


## [22.6.0]

Expand Down
29 changes: 29 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
############################################################
# 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 type hints via mypy
typecheck:
mypy --strict .

# run linter via ruff
lint:
ruff check .

# run tests via pytest
test:
pytest -svv .

# run all checks
checkall:
just formatcheck
just typecheck
just lint
just test
1 change: 0 additions & 1 deletion mdut/__init__.py

This file was deleted.

18 changes: 12 additions & 6 deletions modd.conf
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# tests
**/*.py {
prep: pytest
prep: mypy --strict mdut
prep: flake8
prep: python mdut/mdut.py http://example.com
prep: python mdut/mdut.py -s inline http://example.com
# check formatting via ruff
prep: ruff format --check .

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

# run linter via ruff
prep: ruff check .

# run tests via pytest
prep: pytest -svv .
}

63 changes: 27 additions & 36 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
[tool.poetry]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "mdut"
version = "22.6.0"
dependencies = [
"httpx>=0.27.0",
"beautifulsoup4>=4.12.3",
"pyperclip>=1.9.0",
"click>=8.1.7",
]
requires-python = ">=3.9"
authors = [
{name = "Nik Kantar", email = "[email protected]" },
]
description = "Markdown URL tag generator"
license = "MIT"
authors = ["Nik Kantar <[email protected]>"]
readme = "README.md"
homepage = "https://github.com/nkantar/mdut"
repository = "https://github.com/nkantar/mdut"
documentation = "https://github.com/nkantar/mdut"

keywords = ["markdown"]
license = {file = "LICENSE"}
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Software Development :: Code Generators",
"Topic :: Software Development :: Libraries",
Expand All @@ -25,33 +35,14 @@ classifiers = [
"Typing :: Typed",
]

packages = [
{ include = "mdut" },
]
[project.scripts]
mdut = "src.mdut:mdut"

include = [
"CHANGELOG.md",
"LICENSE",
"README.md",
[tool.uv]
dev-dependencies = [
"ruff>=0.6.2",
"pytest>=8.3.2",
"mypy>=1.11.2",
"pdbpp>=0.10.3",
"types-beautifulsoup4>=4.12.0.20240511",
]

[tool.poetry.dependencies]
python = "^3.7"
httpx = "^0.23.0"
beautifulsoup4 = "^4.11.1"
pyperclip = "^1.8.2"
click = "^8.1.3"

[tool.poetry.dev-dependencies]
black = "^22.3.0"
pytest = "^7.1.2"
mypy = "^0.960"
flake8 = "^4.0.1"
types-beautifulsoup4 = "^4.11.1"

[tool.poetry.scripts]
mdut = "mdut.mdut:mdut"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
1 change: 1 addition & 0 deletions src/mdut/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Main mdut module."""
File renamed without changes.
Empty file added src/mdut/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 mdut."""
4 changes: 2 additions & 2 deletions tests/test_extract_title.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
),
],
)
def test_valid(html, title):
def test_valid(html: str, title: str) -> None:
assert extract_title(html) == title


Expand All @@ -35,5 +35,5 @@ def test_valid(html, title):
int,
],
)
def test_invalid(html):
def test_invalid(html: str) -> None:
assert extract_title(html) == "TODO"
6 changes: 3 additions & 3 deletions tests/test_generate_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
("foo", None, '[TODO]: foo "TODO"'),
],
)
def test_reference(url, title, tag):
def test_reference(url: str, title: str, tag: str) -> None:
assert generate_tag(url, title, "reference") == tag


Expand All @@ -23,7 +23,7 @@ def test_reference(url, title, tag):
("foo", None, '[TODO](foo "TODO")'),
],
)
def test_inline(url, title, tag):
def test_inline(url: str, title: str, tag: str) -> None:
assert generate_tag(url, title, "inline") == tag


Expand All @@ -35,5 +35,5 @@ def test_inline(url, title, tag):
("foo", None, "[TODO](foo)"),
],
)
def test_slack(url, title, tag):
def test_slack(url: str, title: str, tag: str) -> None:
assert generate_tag(url, title, "slack") == tag
Loading

0 comments on commit 1c5837f

Please sign in to comment.