Skip to content

Commit eb7f2a0

Browse files
committed
modernize project
1 parent 3223fb6 commit eb7f2a0

File tree

7 files changed

+49
-30
lines changed

7 files changed

+49
-30
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ jobs:
2626
- uses: actions/setup-python@v5
2727
with:
2828
python-version: 3.8
29-
- run: python -m pip install --upgrade build twine
30-
- run: python -m build
31-
- run: twine check --strict dist/*
29+
- uses: astral-sh/setup-uv@v6
30+
- run: uv build
31+
- run: uv tool run twine check --strict dist/*
3232
- uses: actions/upload-artifact@v4
3333
with:
3434
name: Packages

.github/workflows/ci.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ permissions:
1616
contents: read
1717

1818
jobs:
19-
pre-commit:
19+
tests:
2020
runs-on: ubuntu-latest
2121
steps:
2222
- uses: actions/checkout@v4
@@ -25,6 +25,7 @@ jobs:
2525
- uses: actions/setup-python@v5
2626
with:
2727
python-version: "3.8"
28-
- uses: pre-commit/[email protected]
29-
- run: pip install -e ".[tests]"
28+
- uses: astral-sh/setup-uv@v6
29+
- uses: pre-commit/[email protected]
30+
- run: uv pip install . --group tests
3031
- run: pytest

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: 'v0.1.9'
3+
rev: 'v0.12.1'
44
hooks:
55
- id: ruff
66
args: [--fix, --exit-non-zero-on-fix]
77
- id: ruff-format
88
- repo: https://github.com/codespell-project/codespell
9-
rev: v2.2.6
9+
rev: v2.4.1
1010
hooks:
1111
- id: codespell
1212
additional_dependencies: ["tomli"]
1313
- repo: https://github.com/pre-commit/mirrors-mypy
14-
rev: 'v1.8.0'
14+
rev: 'v1.16.1'
1515
hooks:
1616
- id: mypy
17-
exclude: '^tests/'
17+
additional_dependencies: ["pytest", "hypothesis"]

bscal.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,9 @@ def ad_to_bs(ad: date, start: Optional[int] = None) -> Tuple[int, int, int]:
317317

318318

319319
class BSCalendar(calendar.TextCalendar):
320-
def __init__(self, firstweekday: int = 0, to_highlight: Tuple[int, ...] = ()):
320+
def __init__(
321+
self, firstweekday: int = 0, to_highlight: Tuple[int, ...] = ()
322+
) -> None:
321323
super().__init__(firstweekday)
322324
self._to_highlight = to_highlight
323325
self._formatting_ctx: Tuple[int, ...] = ()
@@ -356,7 +358,8 @@ def formatday(self, day: int, weekday: int, width: int) -> str:
356358

357359

358360
def bsconv(bs_datestring: str) -> None:
359-
ad = bs_to_ad(*map(int, bs_datestring.split("-")[:3]))
361+
year, month, day, *_ = map(int, bs_datestring.split("-"))
362+
ad = bs_to_ad(year, month, day)
360363
ad_tz = datetime.combine(ad, datetime.now().time()).astimezone()
361364
print(ad_tz.strftime("%a %b %e %T %Z %Y"))
362365

pyproject.toml

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,43 @@ dynamic = ["version"]
1515
bscal = "bscal:cal"
1616
bsdate = "bscal:bsdate"
1717

18-
[project.optional-dependencies]
18+
[dependency-groups]
1919
tests = ["pytest", "hypothesis"]
20-
21-
[tool.setuptools]
22-
license-files = ["LICENSE"]
20+
dev = [{ include-group = 'tests' }]
2321

2422
[tool.setuptools_scm]
2523

2624
[tool.mypy]
2725
check_untyped_defs = true
28-
files = ["bscal.py"]
26+
files = ["bscal.py", "tests"]
2927
strict = true
3028

3129
[tool.ruff]
32-
ignore = ["ISC001", "S101"]
33-
select = [
34-
"F", "E", "W", "C90", "I", "N", "UP", "YTT", "ASYNC", "S", "BLE", "B", "A", "C4", "T10",
35-
"EXE", "ISC", "ICN", "G", "INP", "PIE", "PYI", "PT", "Q", "RSE", "RET",
36-
"SLOT", "SIM", "TID", "TCH", "ARG", "PGH", "PLC", "PLE", "PLR", "PLW", "TRY",
37-
"FLY", "PERF101", "RUF",
38-
]
39-
show-source = true
30+
output-format = "full"
4031
show-fixes = true
4132

33+
[tool.ruff.lint]
34+
ignore = [
35+
"ISC001",
36+
"S101",
37+
"PLC0415",
38+
"D1",
39+
"FA",
40+
"T201",
41+
"EM",
42+
"FBT",
43+
"ERA",
44+
"D2",
45+
"DTZ",
46+
"COM",
47+
]
48+
select = ["ALL"]
49+
4250
[tool.ruff.format]
4351
preview = true
4452

45-
[tool.ruff.flake8-type-checking]
53+
[tool.ruff.lint.flake8-type-checking]
4654
strict = true
4755

48-
[tool.ruff.flake8-unused-arguments]
56+
[tool.ruff.lint.flake8-unused-arguments]
4957
ignore-variadic-names = true

tests/test_cli.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@
6060
(("2080",), results_2080),
6161
],
6262
)
63-
def test_cli(capsys, args, expected):
63+
def test_cli(
64+
capsys: pytest.CaptureFixture[str],
65+
args: tuple[str, str],
66+
expected: str,
67+
) -> None:
6468
cal(args)
6569
out, err = capsys.readouterr()
6670
assert out == expected

tests/test_conversion.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
from datetime import date
2+
13
from hypothesis import given
24
from hypothesis.strategies import dates
35

46
from bscal import ad_to_bs, bs_to_ad, new_years
57

68

79
@given(dates(min(new_years.values()), max(new_years.values())))
8-
def test(date):
9-
assert bs_to_ad(*ad_to_bs(date)) == date
10+
def test(date: date) -> None:
11+
bs_year, bs_month, bs_day = ad_to_bs(date)
12+
assert bs_to_ad(bs_year, bs_month, bs_day) == date

0 commit comments

Comments
 (0)