Skip to content

Commit

Permalink
Switch to rye (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmke8 authored Feb 23, 2024
2 parents 58d4b68 + 0f63434 commit 20c57ad
Show file tree
Hide file tree
Showing 12 changed files with 126 additions and 285 deletions.
50 changes: 18 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- main
merge_group:

jobs:
lint_with_ruff:

Expand All @@ -19,22 +20,15 @@ jobs:
working-directory: ${{ matrix.directory }}

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install ruff
run: |
python -m pip install --upgrade pip
pip install ruff
- name: Lint with ruff
run: |
ruff check --output-format=github type_enum*
- name: Format with ruff
run: |
ruff format --check type_enum*
- uses: actions/checkout@v3
- name: Install rye
uses: eifinger/setup-rye@v1
- name: Lint with ruff
run: |
rye lint -- --output-format=github
- name: Format with ruff
run: |
rye fmt -- --diff type_enum*
run_tests:
runs-on: ubuntu-latest
Expand All @@ -45,19 +39,15 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install rye
uses: eifinger/setup-rye@v1

- name: Install dependencies
run: |
poetry env use 3.11
poetry install --no-interaction --no-root
rye sync --no-lock
- name: Run tests
run: |
poetry run python -m unittest -v
rye run test -v
type_check:
runs-on: ubuntu-latest
Expand All @@ -68,16 +58,12 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install rye
uses: eifinger/setup-rye@v1

- name: Install dependencies
run: |
poetry env use 3.11
poetry install --no-interaction --no-root
rye sync --no-lock
- name: Run type check
run: |
poetry run mypy tests
rye run mypy tests
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,3 @@ dmypy.json

# Pyre type checker
.pyre/

# project-specific
/type-enum/README.md
10 changes: 5 additions & 5 deletions make_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -e
version_bump=$1

case $version_bump in
"patch" | "minor" | "major" | "prepatch" | "preminor" | "premajor" | "prerelease")
"patch" | "minor" | "major")
echo "valid version bump: $version_bump"
;;
*)
Expand Down Expand Up @@ -47,7 +47,7 @@ bump_build_publish() {
echo "#######################################"
echo "# bump version #"
echo "#######################################"
poetry version $version_bump
rye version -b $version_bump

echo "#######################################"
echo "# stage pyroject.toml #"
Expand All @@ -57,15 +57,15 @@ bump_build_publish() {
echo "#######################################"
echo "# do new build #"
echo "#######################################"
poetry build
rye build

echo ""
echo "#######################################"
echo "# publish package #"
echo "#######################################"
# to use this, set up an API token with
# `poetry config pypi-token.pypi <api token>`
poetry publish
rye publish

echo "#######################################"
echo "# leaving '$1' #"
Expand All @@ -80,7 +80,7 @@ bump_build_publish "type-enum-plugin"

# get the version from 'type_enum'
pushd type-enum
new_version=$(poetry version -s)
new_version=$(rye version)
popd

echo "#######################################"
Expand Down
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[project]
name = "type-enum-workspace"
version = "0.0.0"
requires-python = ">= 3.11"

[tool.rye]
managed = true
virtual = true

[tool.rye.workspace]
members = ["type-enum*"]
18 changes: 18 additions & 0 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: false
# with-sources: false

-e file:type-enum
-e file:type-enum-plugin
mypy==1.7.1
# via type-enum-plugin
mypy-extensions==1.0.0
# via mypy
ruff==0.2.2
typing-extensions==4.9.0
# via mypy
17 changes: 17 additions & 0 deletions requirements.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: false
# with-sources: false

-e file:type-enum
-e file:type-enum-plugin
mypy==1.8.0
# via type-enum-plugin
mypy-extensions==1.0.0
# via mypy
typing-extensions==4.9.0
# via mypy
99 changes: 0 additions & 99 deletions type-enum-plugin/poetry.lock

This file was deleted.

36 changes: 22 additions & 14 deletions type-enum-plugin/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,34 +1,42 @@
[tool.poetry]
[project]
name = "type-enum-plugin"
version = "0.4.1a0"
description = "Mypy plugin for type-enum."
authors = ["Thomas MK <[email protected]>"]
license = "Apache License 2.0"
authors = [
{ name = "Thomas MK", email = "[email protected]" },
]
license = { text = "Apache-2.0" }
readme = "README.md"
packages = [{ include = "type_enum_plugin" }]
# packages = [{ include = "type_enum_plugin" }]
classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
]
repository = "https://github.com/tmke8/type_enum"
requires-python = ">=3.11"
dependencies = [
"mypy",
]

[tool.poetry.dependencies]
python = "^3.11"
mypy = "*"
[project.urls]
Documentation = "https://github.com/tmke8/type-enum#readme"
Issues = "https://github.com/tmke8/type-enum/issues"
Source = "https://github.com/tmke8/type-enum"

[tool.poetry.group.dev.dependencies]
mypy = "^1.5"
ruff = ">=0.0.292"
[tool.rye]
managed = true
dev-dependencies = ["mypy >= 1.5", "ruff >= 0.0.292"]

[tool.ruff]
line-length = 88

[tool.ruff.lint]
select = [
"I", # isort
]

[tool.ruff.isort]
[tool.ruff.lint.isort]
known-third-party = ["mypy", "pytest"]
extra-standard-library = ["typing_extensions"]
no-lines-before = ["future", "standard-library"]
Expand All @@ -37,5 +45,5 @@ split-on-trailing-comma = false
classes = ["MDEF"]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
requires = ["hatchling"]
build-backend = "hatchling.build"
Empty file added type-enum/README.md
Empty file.
5 changes: 5 additions & 0 deletions type-enum/example.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
from typing import Final

from type_enum import TypeEnum


class BgColor(TypeEnum):
transparent = ()
a = 32
name = (str,)
rgb = {"red": int, "green": int, "blue": int} # named args
hsv = {"hue": int, "saturation": int, "value": int}


reveal_type(BgColor.rgb)
background_color = BgColor.rgb(red=39, green=127, blue=168)
reveal_type(background_color.red)
Expand All @@ -26,4 +30,5 @@ def f(color: BgColor) -> None:
case BgColor.hsv(hue=h, saturation=s, value=v):
print(f"HSV: {h}, {s}, {v}")


f(background_color)
Loading

0 comments on commit 20c57ad

Please sign in to comment.