Skip to content

Commit

Permalink
Replace pipenv with uv (#509)
Browse files Browse the repository at this point in the history
* replace pipenv with uv
* clean up
* drop python 3.10 support
  • Loading branch information
cgtobi authored Sep 16, 2024
1 parent b9d17fd commit 042724e
Show file tree
Hide file tree
Showing 13 changed files with 1,506 additions and 131 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,17 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.10
- name: Set up Python 3.11
uses: actions/[email protected]
with:
python-version: 3.10.8
python-version: 3.11.4
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel build
- name: Build a binary wheel and a source tarball
run: >-
python -m build .
# - name: Publish 📦 to Test PyPI
# uses: pypa/gh-action-pypi-publish@master
# with:
# password: ${{ secrets.PYPI_TEST_TOKEN }}
# repository-url: https://test.pypi.org/legacy/
- name: Publish 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
with:
ref: development
fetch-depth: 0
- name: Set up Python 3.10
- name: Set up Python 3.11
uses: actions/[email protected]
with:
python-version: 3.10.8
python-version: 3.11.4
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: [3.10.8, 3.11.4]
python-version: [3.11.4, 3.12.5]

steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exclude: ^(fixtures/)

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.1
rev: v0.6.4
hooks:
- id: ruff
args:
Expand All @@ -18,7 +18,7 @@ repos:
language_version: python3

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.1
rev: v1.11.2
hooks:
- id: mypy
name: mypy
Expand Down
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

-
- Replaced pipenv with uv and updated readme

### Deprecated

-
- Python 3.10 support

### Removed

Expand All @@ -29,7 +29,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Security


## [8.1.0]

### Added
Expand Down
26 changes: 0 additions & 26 deletions Pipfile

This file was deleted.

13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@ Be aware that the module may stop working if Netatmo decides to change their API

## Development

Clone the repo and install dependencies:
Prerequisits:

git clone
cd pyatmo
pipenv install --dev
uv
python >=3.11

To add the pre-commit hook to your environment run:
Clone the repo, install dependencies and install pre-commit hooks:

pip install pre-commit
git clone
cd pyatmo
uv sync
pre-commit install

## Testing
Expand Down
84 changes: 70 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,80 @@
requires = ["wheel", "setuptools", "attrs>=17.1"]
build-backend = "setuptools.build_meta"

[project]
name = "pyatmo"
description = "Simple API to access Netatmo weather station data from any Python 3 script. Designed for Home Assistant (but not only)"
dynamic = ["version"]
readme = "README.md"
authors = [{ name = "Hugo Dupras", email = "[email protected]" }]
maintainers = [{ name = "Tobias Sauerwein", email = "[email protected]" }]
requires-python = ">=3.11,<3.13"
dependencies = [
"aiohttp>=3.7.4,<4.0.0",
"oauthlib~=3.1",
"requests~=2.24",
"requests-oauthlib>=1.3,<3.0",
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Topic :: Home Automation",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]

[project.urls]
Homepage = "https://github.com/jabesq-org/pyatmo"
Repository = "https://github.com/jabesq-org/pyatmo.git"
Issues = "https://github.com/jabesq-org/pyatmo/issues"
Changelog = "https://github.com/jabesq-org/pyatmo/blob/development/CHANGELOG.md"

[tool.uv]
dev-dependencies = [
"black==24.8.0",
"pre-commit==3.8.0",
"ruff==0.6.4",
"codespell==2.3.0",
"pytest==8.3.3",
"pytest-asyncio==0.24.0",
"pytest-cov==5.0.0",
"docutils==0.21.2",
"time-machine==2.15.0",
"mypy==1.11.2",
"pytest-mock==3.14.0",
"requests-mock==1.12.1",
"tox==4.18.1",
"twine==5.1.1",
]

[tool.setuptools_scm]
local_scheme = "no-local-version"
tag_regex = "^(?P<prefix>v)?(?P<version>[^\\+]+)(?P<suffix>.*)?$"
write_to = "src/pyatmo/__version__.py"
write_to_template = '''"""
Pyatmo: Simple API to access Netatmo devices and data
DO NO EDIT THIS FILE - VERSION IS MANAGED BY SETUPTOOLS_SCM
"""
__version__ = "{version}"
'''

[tool.pytest.ini_options]
minversion = "7.0"
minversion = "8.0"
asyncio_mode = "auto"

[tool.mypy]
ignore_missing_imports = true

[tool.ruff]
target-version = "py310"
target-version = "py311"
fix = true
line-length = 88

[tool.ruff.lint]
select = [
Expand Down Expand Up @@ -113,15 +181,3 @@ split-on-trailing-comma = false

[tool.ruff.lint.mccabe]
max-complexity = 25

[tool.setuptools_scm]
local_scheme = "no-local-version"
tag_regex = "^(?P<prefix>v)?(?P<version>[^\\+]+)(?P<suffix>.*)?$"
write_to = "src/pyatmo/__version__.py"
write_to_template = '''"""
Pyatmo: Simple API to access Netatmo devices and data
DO NO EDIT THIS FILE - VERSION IS MANAGED BY SETUPTOOLS_SCM
"""
__version__ = "{version}"
'''
50 changes: 0 additions & 50 deletions setup.cfg

This file was deleted.

5 changes: 3 additions & 2 deletions src/pyatmo/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,22 +348,23 @@ async def async_set_schedule_temperatures(
]

for zone in selected_schedule.zones:
rooms = []
new_zone = {
"id": zone.entity_id,
"name": zone.name,
"type": zone.type,
"rooms": [],
}

for room in zone.rooms:
temp = room.therm_setpoint_temperature
if zone.entity_id == zone_id and room.entity_id in temps:
temp = temps[room.entity_id]

new_zone["rooms"].append(
rooms.append(
{"id": room.entity_id, "therm_setpoint_temperature": temp},
)

new_zone["rooms"] = rooms
zones.append(new_zone)

schedule = {
Expand Down
13 changes: 5 additions & 8 deletions src/pyatmo/modules/base_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class EntityBase:
home: Home
bridge: str | None
history_features: set[str]
history_features_values: dict[str, [int, int]] | {}
name: str | None
history_features_values: dict
name: str


class NetatmoBase(EntityBase, ABC):
Expand Down Expand Up @@ -110,12 +110,9 @@ def add_history_data(self, feature: str, value, time: int) -> None:
else:
i = bisect.bisect_left(hist_f, time, key=itemgetter(0))

if i < len(hist_f):
if hist_f[i][0] == time:
hist_f[i] = (time, value, self.entity_id)
i = None

if i is not None:
if i < len(hist_f) and hist_f[i][0] == time:
hist_f[i] = (time, value, self.entity_id)
else:
hist_f.insert(i, (time, value, self.entity_id))

# keep timing history to a maximum representative time
Expand Down
Loading

0 comments on commit 042724e

Please sign in to comment.