Skip to content

Commit c1c0a94

Browse files
Migrate to poetry
1 parent a839fc0 commit c1c0a94

File tree

9 files changed

+136
-152
lines changed

9 files changed

+136
-152
lines changed
Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
1-
name: Actions
1+
name: Code Quality
22

33
on:
44
pull_request:
55
branches:
66
- master
77
push:
8-
branches:
9-
- master
108

119
jobs:
12-
lint:
13-
name: Lint
10+
code_quality:
11+
name: Code Quality
1412
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
include:
16+
- id: black
17+
name: Check code style with black
18+
- id: isort
19+
name: Check if imports are sorted with isort
20+
- id: pylint
21+
name: Check code with pylint
22+
- id: mypy
23+
name: Check code with pylint
1524
steps:
1625
- name: Checkout the repository
1726
uses: actions/checkout@v3
@@ -22,20 +31,12 @@ jobs:
2231
with:
2332
python-version: "3.11"
2433

25-
- name: Install dependencies
26-
run: pip install -r requirements.txt
27-
28-
- name: Install dev dependencies
29-
run: pip install -r requirements-dev.txt
30-
31-
- name: Lint with Black
32-
run: black --check src
33-
34-
- name: Lint with mypy
35-
run: mypy --strict src
34+
- name: Install workflow dependencies
35+
run: |
36+
pip install -r .github/workflows/requirements.txt
3637
37-
- name: Lint with pylint
38-
run: pylint src --rcfile pylint.rc
38+
- name: Install Python dependencies
39+
run: poetry install --no-interaction
3940

40-
- name: Lint with isort
41-
run: isort --check-only --profile black src
41+
- name: Run ${{ matrix.id }} checks
42+
run: poetry run ${{ matrix.id }} src

.github/workflows/release.yml

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,43 @@
1-
name: Publish releases
1+
name: Publish release
22

33
on:
44
release:
55
types: [published]
66

77
jobs:
88
build-and-publish-pypi:
9-
name: Builds and publishes releases to PyPI
9+
name: Builds and publishes release to PyPI
1010
runs-on: ubuntu-latest
1111
outputs:
1212
version: ${{ steps.vars.outputs.tag }}
1313
steps:
1414
- uses: actions/checkout@v3.5.3
15-
- name: Get tag
16-
id: vars
17-
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
15+
1816
- name: Set up Python 3.11
1917
uses: actions/setup-python@v4.7.0
2018
with:
2119
python-version: "3.11"
22-
- name: Install build
23-
run: >-
24-
pip install build tomli tomli-w
25-
- name: Set Python project version from tag
26-
shell: python
27-
run: |-
28-
import tomli
29-
import tomli_w
30-
31-
with open("pyproject.toml", "rb") as f:
32-
pyproject = tomli.load(f)
33-
34-
pyproject["project"]["version"] = "${{ steps.vars.outputs.tag }}"
35-
36-
with open("pyproject.toml", "wb") as f:
37-
tomli_w.dump(pyproject, f)
38-
- name: Build
39-
run: >-
40-
python3 -m build
41-
- name: Publish release to PyPI
42-
uses: pypa/gh-action-pypi-publish@v1.8.10
43-
with:
44-
user: __token__
45-
password: ${{ secrets.PYPI_TOKEN }}
20+
21+
- name: Install workflow dependencies
22+
run: |
23+
pip install -r .github/workflows/requirements.txt
24+
25+
- name: Install dependencies
26+
run: poetry install --no-interaction
27+
28+
- name: Set package version
29+
run: |
30+
version="${{ github.event.release.tag_name }}"
31+
version="${version,,}"
32+
version="${version#v}"
33+
poetry version --no-interaction "${version}"
34+
35+
- name: Build package
36+
run: poetry build --no-interaction
37+
38+
- name: Publish to PyPi
39+
env:
40+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
41+
run: |
42+
poetry config pypi-token.pypi "${PYPI_TOKEN}"
43+
poetry publish --no-interaction

.github/workflows/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pip==23.2.1
2+
poetry==1.5.1

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
[pypi_releases_shield]: https://img.shields.io/pypi/v/vacuum-map-parser-base
1515

1616
[pypi_downloads]: https://pepy.tech/project/vacuum-map-parser-base
17-
[pypi_downloads_shield]: https://pepy.tech/badge/vacuum-map-parser-base/month
17+
[pypi_downloads_shield]: https://static.pepy.tech/badge/vacuum-map-parser-base
1818

1919
# Vacuum map parser - base
2020

@@ -24,7 +24,7 @@ Available implementations:
2424
* [`vacuum-map-parser-roborock`](https://github.com/PiotrMachowski/Python-package-vacuum-map-parser-roborock)
2525
* [`vacuum-map-parser-viomi`](https://github.com/PiotrMachowski/Python-package-vacuum-map-parser-viomi)
2626
* [`vacuum-map-parser-roidmi`](https://github.com/PiotrMachowski/Python-package-vacuum-map-parser-roidmi)
27-
* [`vacuum-map-parser-viomi`](https://github.com/PiotrMachowski/Python-package-vacuum-map-parser-viomi)
27+
* [`vacuum-map-parser-dreame`](https://github.com/PiotrMachowski/Python-package-vacuum-map-parser-dreame)
2828

2929
## Installation
3030

pyproject.toml

Lines changed: 54 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,71 @@
1-
[build-system]
2-
requires = ["setuptools"]
3-
build-backend = "setuptools.build_meta"
4-
5-
[project]
1+
[tool.poetry]
62
name = "vacuum-map-parser-base"
73
# The version is set by GH action on release
84
version = "0.0.0"
9-
license = { text = "Apache-2.0" }
5+
license = "Apache-2.0"
106
description = "Common code for vacuum map parsers"
117
readme = "README.md"
12-
requires-python = ">=3.11"
13-
authors = [
14-
{ name = "Piotr Machowski", email = "piotr.machowski.dev@gmail.com" }
15-
]
8+
authors = ["Piotr Machowski <piotr.machowski.dev@gmail.com>"]
169
classifiers = [
1710
"Development Status :: 4 - Beta",
1811
"Intended Audience :: Developers",
1912
"Environment :: Console",
2013
"Programming Language :: Python :: 3.11",
2114
"Topic :: Home Automation",
2215
]
23-
dynamic = ["dependencies"]
16+
packages = [
17+
{ include = "vacuum_map_parser_base", from = "src" },
18+
]
2419

25-
[project.urls]
20+
[tool.poetry.urls]
2621
"Homepage" = "https://github.com/PiotrMachowski/Python-package-vacuum-map-parser-base"
2722
"Repository" = "https://github.com/PiotrMachowski/Python-package-vacuum-map-parser-base"
2823
"Bug Tracker" = "https://github.com/PiotrMachowski/Python-package-vacuum-map-parser-base/issues"
24+
"Changelog" = "https://github.com/PiotrMachowski/Python-package-vacuum-map-parser-base/releases"
25+
26+
[tool.poetry.dependencies]
27+
python = "^3.11"
28+
Pillow = "*"
29+
30+
[tool.poetry.dev-dependencies]
31+
black = "*"
32+
mypy = "*"
33+
ruff = "*"
34+
isort = "*"
35+
pylint = "*"
36+
types-Pillow = "*"
2937

30-
[tool.setuptools.dynamic]
31-
dependencies = { file = ["requirements.txt"] }
32-
optional-dependencies = {dev = { file = ["requirements-dev.txt"] }}
38+
[tool.black]
39+
line-length = 120
40+
41+
[tool.isort]
42+
profile = "black"
43+
line_length = 120
44+
45+
[tool.mypy]
46+
platform = "linux"
47+
48+
check_untyped_defs = true
49+
disallow_any_generics = true
50+
disallow_incomplete_defs = true
51+
disallow_subclassing_any = true
52+
disallow_untyped_calls = true
53+
disallow_untyped_defs = true
54+
disallow_untyped_decorators = true
55+
no_implicit_optional = true
56+
no_implicit_reexport = true
57+
strict_optional = true
58+
warn_incomplete_stub = true
59+
warn_no_return = true
60+
warn_redundant_casts = true
61+
warn_return_any = true
62+
warn_unused_configs = true
63+
warn_unused_ignores = true
64+
65+
[tool.pylint]
66+
disable = ["C0103", "C0116", "R0902", "R0903", "R0913", "R0914", "W0640"]
67+
max-line-length = 120
68+
69+
[build-system]
70+
requires = ["poetry-core>=1.0.0"]
71+
build-backend = "poetry.core.masonry.api"

src/vacuum_map_parser_base/config/color.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,7 @@ def __init__(
121121
def get_color(self, color_name: SupportedColor) -> Color:
122122
return self._overriden_colors.get(
123123
color_name,
124-
ColorsPalette.COLORS.get(
125-
color_name, ColorsPalette.COLORS.get(SupportedColor.UNKNOWN, (0, 0, 0))
126-
),
124+
ColorsPalette.COLORS.get(color_name, ColorsPalette.COLORS.get(SupportedColor.UNKNOWN, (0, 0, 0))),
127125
)
128126

129127
def get_room_color(self, room_id: str | int) -> Color:
@@ -137,8 +135,6 @@ def get_room_color(self, room_id: str | int) -> Color:
137135
key,
138136
ColorsPalette.ROOM_COLORS.get(
139137
key,
140-
ColorsPalette.ROOM_COLORS.get(
141-
str(self._random.randint(1, 16)), (0, 0, 0)
142-
),
138+
ColorsPalette.ROOM_COLORS.get(str(self._random.randint(1, 16)), (0, 0, 0)),
143139
),
144140
)

0 commit comments

Comments
 (0)