Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use rye #551

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
"files.trimTrailingWhitespace": true,
"python.analysis.autoImportCompletions": true,
"python.analysis.autoSearchPaths": false,
"python.analysis.extraPaths": ["/home/vscode/.local/lib/python3.12/"],
"python.analysis.extraPaths": [
"/home/vscode/.local/lib/python3.12/"
],
"python.analysis.typeCheckingMode": "basic",
"python.defaultInterpreterPath": "/usr/local/bin/python",
"python.languageServer": "Pylance",
Expand All @@ -48,13 +50,16 @@
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},
"image": "mcr.microsoft.com/devcontainers/python:3",
"image": "jfxs/devcontainer-rye",
"name": "Deebot client",
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
"postStartCommand": "pip install -r requirements-dev.txt && pre-commit install && pip install -e .",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",
"runArgs": ["-e", "GIT_EDITOR=code --wait"]
}
"runArgs": [
"-e",
"GIT_EDITOR=code --wait"
]
}
70 changes: 38 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---

Check failure on line 1 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / code-quality (3.12)

1:1 [document-start] found forbidden document start "---"
name: CI

on:
Expand All @@ -6,34 +7,39 @@
- main
- dev
pull_request:

env:
DEFAULT_PYTHON: "3.12"
workflow_dispatch:
schedule:
- cron: "0 0 * * *"

jobs:
code-quality:
runs-on: "ubuntu-latest"
name: Check code quality
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
steps:
- uses: "actions/checkout@v4"
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/[email protected]
- uses: actions/checkout@v4
- uses: eifinger/setup-rye@v4
id: setup-rye
with:
python-version: ${{ env.DEFAULT_PYTHON }}
cache: "pip"
cache-dependency-path: "requirements*"
enable-cache: true
cache-prefix: ${{ matrix.python-version }}
- name: Pin python-version ${{ matrix.python-version }}
run: rye pin ${{ matrix.python-version }}
- name: Install dependencies
if: steps.setup-rye.outputs.cache-hit != 'true'
run: |
rye sync --no-lock
- name: Cache pre-commit
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-|${{ matrix.python-version }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Lint
run: |
pip install -r requirements.txt
pip install -r requirements-test.txt
# Following steps cannot run by pre-commit.ci as repo = local
- name: Run mypy
run: mypy deebot_client/
- name: Pylint review
run: pylint deebot_client/
- name: Verify no getLogger usages
run: scripts/check_getLogger.sh
rye run pre-commit run --all-files
- name: Lint GitHub Actions
uses: eifinger/actionlint-action@v1

tests:
runs-on: "ubuntu-latest"
Expand All @@ -42,20 +48,20 @@
matrix:
python-version: ["3.12"]
steps:
- uses: "actions/checkout@v4"
- name: Set up Python ${{ matrix.python-version }}
id: python
uses: actions/[email protected]
- uses: actions/checkout@v4
- uses: eifinger/setup-rye@v4
id: setup-rye
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "requirements*"
enable-cache: true
cache-prefix: ${{ matrix.python-version }}
- name: Pin python-version ${{ matrix.python-version }}
run: rye pin ${{ matrix.python-version }}
- name: Install dependencies
if: steps.setup-rye.outputs.cache-hit != 'true'
run: |
pip install -r requirements.txt
pip install -r requirements-test.txt
- name: Run pytest
run: pytest --cov=./ --cov-report=xml
rye sync --no-lock
- name: Execute tests
run: rye test -- --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
Expand Down
16 changes: 4 additions & 12 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,11 @@ jobs:
steps:
- name: 📥 Checkout the repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/[email protected]
- uses: eifinger/setup-rye@v4
with:
python-version: "3.12"

- name: Install dependencies
enable-cache: true
- name: 📦 Build
run: |
python -m pip install --upgrade pip
pip install -q build

- name: 📦 Build package
run: python -m build

rye build
- name: 📤 Publish package
uses: pypa/gh-action-pypi-publish@release/v1
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ scratch*
.idea
build
dist
venv
.venv

# Nosetests files
cover/
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.4
54 changes: 38 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[build-system]
requires = ["setuptools>=60",
"setuptools-scm>=8.0"]
build-backend = "setuptools.build_meta"
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[project]
name = "deebot-client"
Expand All @@ -21,27 +20,48 @@ classifiers = [
"Topic :: Software Development :: Libraries :: Python Modules",
]
requires-python = ">=3.12.0"
dynamic = ["dependencies", "version"]
dynamic = ["version"]
dependencies = [
"aiohttp~=3.10",
"aiomqtt>=2.0.0, <3.0",
"cachetools>=5.0.0,<6.0",
"defusedxml",
"numpy>=1.23.2,<3.0",
"Pillow>=10.0.1,<11.0",
"svg.py>=1.4.2",
]

[project.urls]
"Homepage" = "https://deebot.readthedocs.io/"
"Source Code" = "https://github.com/DeebotUniverse/client.py"
"Bug Reports" = "https://github.com/DeebotUniverse/client.py/issues"

[tool.setuptools]
include-package-data = true

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}
[tool.rye]
managed = true
dev-dependencies = [
"mypy==1.11.1",
"pre-commit==3.8.0",
"pycountry==24.6.1",
"pylint==3.2.6",
"pytest==8.3.2",
"pytest-asyncio==0.23.8",
"pytest-cov==5.0.0",
"pytest-docker-fixtures==1.3.19",
"pytest-timeout==2.3.1",
"testfixtures==8.3.0",
"types-cachetools",
"types-mock",
"types-Pillow",
]

[tool.setuptools.packages.find]
include = ["deebot_client*"]
[tool.hatch.metadata]
allow-direct-references = true

[tool.setuptools_scm]
[tool.black]
target-version = ['py311']
safe = true
[tool.hatch.build.targets.wheel]
packages = ["src/deebot_client"]

[tool.hatch.version]
source = "vcs"


[tool.ruff.lint]
Expand Down Expand Up @@ -173,4 +193,6 @@ expected-line-ending-format = "LF"
overgeneral-exceptions = [
"builtins.BaseException",
"builtins.Exception",
]
]


113 changes: 113 additions & 0 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# 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
# generate-hashes: false
# universal: false

-e file:.
aiohappyeyeballs==2.3.4
# via aiohttp
aiohttp==3.10.0
# via deebot-client
aiomqtt==2.2.0
# via deebot-client
aiosignal==1.3.1
# via aiohttp
astroid==3.2.4
# via pylint
attrs==23.2.0
# via aiohttp
cachetools==5.4.0
# via deebot-client
certifi==2024.7.4
# via requests
cfgv==3.4.0
# via pre-commit
charset-normalizer==3.3.2
# via requests
coverage==7.6.0
# via pytest-cov
defusedxml==0.7.1
# via deebot-client
dill==0.3.8
# via pylint
distlib==0.3.8
# via virtualenv
docker==7.1.0
# via pytest-docker-fixtures
filelock==3.15.4
# via virtualenv
frozenlist==1.4.1
# via aiohttp
# via aiosignal
identify==2.6.0
# via pre-commit
idna==3.7
# via requests
# via yarl
iniconfig==2.0.0
# via pytest
isort==5.13.2
# via pylint
mccabe==0.7.0
# via pylint
multidict==6.0.5
# via aiohttp
# via yarl
mypy==1.11.1
mypy-extensions==1.0.0
# via mypy
nodeenv==1.9.1
# via pre-commit
numpy==2.0.1
# via deebot-client
packaging==24.1
# via pytest
paho-mqtt==2.1.0
# via aiomqtt
pillow==10.4.0
# via deebot-client
platformdirs==4.2.2
# via pylint
# via virtualenv
pluggy==1.5.0
# via pytest
pre-commit==3.8.0
pycountry==24.6.1
pylint==3.2.6
pytest==8.3.2
# via pytest-asyncio
# via pytest-cov
# via pytest-docker-fixtures
# via pytest-timeout
pytest-asyncio==0.23.8
pytest-cov==5.0.0
pytest-docker-fixtures==1.3.19
pytest-timeout==2.3.1
pyyaml==6.0.1
# via pre-commit
requests==2.32.3
# via docker
# via pytest-docker-fixtures
svg-py==1.4.3
# via deebot-client
testfixtures==8.3.0
tomlkit==0.13.0
# via pylint
types-cachetools==5.4.0.20240717
types-mock==5.1.0.20240425
types-pillow==10.2.0.20240520
typing-extensions==4.12.2
# via mypy
urllib3==2.2.2
# via docker
# via requests
virtualenv==20.26.3
# via pre-commit
yarl==1.9.4
# via aiohttp
2 changes: 0 additions & 2 deletions requirements-dev.txt

This file was deleted.

13 changes: 0 additions & 13 deletions requirements-test.txt

This file was deleted.

Loading
Loading