Skip to content

Commit a7ecb52

Browse files
authored
Merge pull request #143 from dknowles2/bump-py
Upgrade required python to 3.12
2 parents 162aa35 + 7693840 commit a7ecb52

File tree

7 files changed

+35
-29
lines changed

7 files changed

+35
-29
lines changed

.devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Python 3",
3-
"image": "mcr.microsoft.com/devcontainers/python:0-3.10-bullseye",
3+
"image": "mcr.microsoft.com/devcontainers/python:1-3.12",
44
"postCreateCommand": "scripts/setup",
55
"customizations": {
66
"vscode": {

.github/workflows/build-and-test.yml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,21 @@ on:
99
pull_request:
1010
branches: [ "main" ]
1111

12+
13+
env:
14+
PYTHON_VERSION: "3.12"
15+
1216
jobs:
1317
build_and_test:
1418
runs-on: ubuntu-latest
1519
strategy:
1620
fail-fast: false
17-
matrix:
18-
python-version: ["3.8", "3.9", "3.10"]
1921
steps:
2022
- uses: actions/checkout@v4
21-
- name: Set up Python ${{ matrix.python-version }}
23+
- name: Set up Python ${{ env.PYTHON_VERSION }}
2224
uses: actions/setup-python@v5
2325
with:
24-
python-version: ${{ matrix.python-version }}
26+
python-version: ${{ env.PYTHON_VERSION }}
2527
- name: Install dependencies
2628
run: |
2729
python -m pip install --upgrade pip
@@ -33,14 +35,12 @@ jobs:
3335
runs-on: ubuntu-latest
3436
strategy:
3537
fail-fast: false
36-
matrix:
37-
python-version: ["3.8", "3.9", "3.10"]
3838
steps:
3939
- uses: actions/checkout@v4
40-
- name: Set up Python ${{ matrix.python-version }}
40+
- name: Set up Python ${{ env.PYTHON_VERSION }}
4141
uses: actions/setup-python@v5
4242
with:
43-
python-version: ${{ matrix.python-version }}
43+
python-version: ${{ env.PYTHON_VERSION }}
4444
- name: Install dependencies
4545
run: |
4646
python -m pip install --upgrade pip
@@ -52,14 +52,12 @@ jobs:
5252
runs-on: ubuntu-latest
5353
strategy:
5454
fail-fast: false
55-
matrix:
56-
python-version: ["3.8", "3.9", "3.10"]
5755
steps:
5856
- uses: actions/checkout@v4
59-
- name: "Set up Python ${{ matrix.python-version }}"
57+
- name: "Set up Python ${{ env.PYTHON_VERSION }}"
6058
uses: actions/setup-python@v5
6159
with:
62-
python-version: ${{ matrix.python-version }}
60+
python-version: ${{ env.PYTHON_VERSION }}
6361
- name: Install dependencies
6462
run: |
6563
python -m pip install --upgrade pip

.github/workflows/publish-python.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@ on:
44
release:
55
types: [published]
66

7+
env:
8+
PYTHON_VERSION: "3.12"
9+
710
jobs:
811
deploy:
9-
1012
runs-on: ubuntu-latest
11-
1213
steps:
1314
- uses: actions/checkout@v4
1415
- name: Set up Python
1516
uses: actions/setup-python@v5
1617
with:
17-
python-version: '3.x'
18+
python-version: ${{ env.PYTHON_VERSION }}
1819
- name: Install dependencies
1920
run: |
2021
python -m pip install --upgrade pip

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 2
33
build:
44
os: ubuntu-22.04
55
tools:
6-
python: "3.10"
6+
python: "3.12"
77

88
python:
99
install:

pyproject.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@ authors = [
99
{name = "David Knowles", email = "dknowles2@gmail.com"},
1010
]
1111
dependencies = ["pycognito", "requests"]
12-
requires-python = ">=3.8"
12+
requires-python = ">=3.12"
1313
dynamic = ["readme", "version"]
1414
license = {text = "Apache License 2.0"}
1515
keywords = ["schlage", "api", "iot"]
1616
classifiers = [
17-
"Programming Language :: Python :: 3.10",
18-
"Programming Language :: Python :: 3.8",
19-
"Programming Language :: Python :: 3.9",
17+
"Programming Language :: Python :: 3.12",
2018
"Topic :: Software Development :: Libraries :: Python Modules",
2119
]
2220

pyschlage/code.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
from dataclasses import astuple, dataclass, field
6-
from datetime import datetime, timezone
6+
from datetime import UTC, datetime, timezone
77

88
from .common import Mutable
99
from .exceptions import NotAuthenticatedError
@@ -34,8 +34,12 @@ def from_json(cls, json) -> TemporarySchedule:
3434
:meta private:
3535
"""
3636
return TemporarySchedule(
37-
start=datetime.utcfromtimestamp(json["activationSecs"]),
38-
end=datetime.utcfromtimestamp(json["expirationSecs"]),
37+
start=datetime.fromtimestamp(json["activationSecs"], UTC).replace(
38+
tzinfo=None
39+
),
40+
end=datetime.fromtimestamp(json["expirationSecs"], UTC).replace(
41+
tzinfo=None
42+
),
3943
)
4044

4145
def to_json(self) -> dict:
@@ -222,7 +226,8 @@ def to_json(self) -> dict:
222226
def refresh(self):
223227
"""Refreshes the AccessCode state.
224228
225-
:raise pyschlage.exceptions.NotAuthenticatedError: When the user is not authenticated.
229+
:raise pyschlage.exceptions.NotAuthenticatedError: When the user is not
230+
authenticated.
226231
:raise pyschlage.exceptions.NotAuthorizedError: When authentication fails.
227232
:raise pyschlage.exceptions.UnknownError: On other errors.
228233
"""
@@ -235,7 +240,8 @@ def refresh(self):
235240
def save(self):
236241
"""Commits changes to the access code.
237242
238-
:raise pyschlage.exceptions.NotAuthenticatedError: When the user is not authenticated.
243+
:raise pyschlage.exceptions.NotAuthenticatedError: When the user is not
244+
authenticated.
239245
:raise pyschlage.exceptions.NotAuthorizedError: When authentication fails.
240246
:raise pyschlage.exceptions.UnknownError: On other errors.
241247
"""
@@ -248,7 +254,8 @@ def save(self):
248254
def delete(self):
249255
"""Deletes the access code.
250256
251-
:raise pyschlage.exceptions.NotAuthenticatedError: When the user is not authenticated.
257+
:raise pyschlage.exceptions.NotAuthenticatedError: When the user is not
258+
authenticated.
252259
:raise pyschlage.exceptions.NotAuthorizedError: When authentication fails.
253260
:raise pyschlage.exceptions.UnknownError: On other errors.
254261
"""

pyschlage/log.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
from dataclasses import dataclass
6-
from datetime import datetime
6+
from datetime import UTC, datetime
77
import time
88

99
_DEFAULT_UUID = "ffffffff-ffff-ffff-ffff-ffffffffffff"
@@ -59,7 +59,9 @@
5959
def _utc2local(utc: datetime) -> datetime:
6060
"""Converts a UTC datetime to localtime."""
6161
epoch = time.mktime(utc.timetuple())
62-
offset = datetime.fromtimestamp(epoch) - datetime.utcfromtimestamp(epoch)
62+
offset = datetime.fromtimestamp(epoch) - datetime.fromtimestamp(epoch, UTC).replace(
63+
tzinfo=None
64+
)
6365
return (utc + offset).replace(tzinfo=None)
6466

6567

0 commit comments

Comments
 (0)