Skip to content

Commit

Permalink
Merge pull request #143 from dknowles2/bump-py
Browse files Browse the repository at this point in the history
Upgrade required python to 3.12
  • Loading branch information
dknowles2 committed Jun 9, 2024
2 parents 162aa35 + 7693840 commit a7ecb52
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Python 3",
"image": "mcr.microsoft.com/devcontainers/python:0-3.10-bullseye",
"image": "mcr.microsoft.com/devcontainers/python:1-3.12",
"postCreateCommand": "scripts/setup",
"customizations": {
"vscode": {
Expand Down
22 changes: 10 additions & 12 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@ on:
pull_request:
branches: [ "main" ]


env:
PYTHON_VERSION: "3.12"

jobs:
build_and_test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -33,14 +35,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -52,14 +52,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v4
- name: "Set up Python ${{ matrix.python-version }}"
- name: "Set up Python ${{ env.PYTHON_VERSION }}"
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/publish-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ on:
release:
types: [published]

env:
PYTHON_VERSION: "3.12"

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "3.10"
python: "3.12"

python:
install:
Expand Down
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ authors = [
{name = "David Knowles", email = "dknowles2@gmail.com"},
]
dependencies = ["pycognito", "requests"]
requires-python = ">=3.8"
requires-python = ">=3.12"
dynamic = ["readme", "version"]
license = {text = "Apache License 2.0"}
keywords = ["schlage", "api", "iot"]
classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.12",
"Topic :: Software Development :: Libraries :: Python Modules",
]

Expand Down
19 changes: 13 additions & 6 deletions pyschlage/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

from dataclasses import astuple, dataclass, field
from datetime import datetime, timezone
from datetime import UTC, datetime, timezone

from .common import Mutable
from .exceptions import NotAuthenticatedError
Expand Down Expand Up @@ -34,8 +34,12 @@ def from_json(cls, json) -> TemporarySchedule:
:meta private:
"""
return TemporarySchedule(
start=datetime.utcfromtimestamp(json["activationSecs"]),
end=datetime.utcfromtimestamp(json["expirationSecs"]),
start=datetime.fromtimestamp(json["activationSecs"], UTC).replace(
tzinfo=None
),
end=datetime.fromtimestamp(json["expirationSecs"], UTC).replace(
tzinfo=None
),
)

def to_json(self) -> dict:
Expand Down Expand Up @@ -222,7 +226,8 @@ def to_json(self) -> dict:
def refresh(self):
"""Refreshes the AccessCode state.
:raise pyschlage.exceptions.NotAuthenticatedError: When the user is not authenticated.
:raise pyschlage.exceptions.NotAuthenticatedError: When the user is not
authenticated.
:raise pyschlage.exceptions.NotAuthorizedError: When authentication fails.
:raise pyschlage.exceptions.UnknownError: On other errors.
"""
Expand All @@ -235,7 +240,8 @@ def refresh(self):
def save(self):
"""Commits changes to the access code.
:raise pyschlage.exceptions.NotAuthenticatedError: When the user is not authenticated.
:raise pyschlage.exceptions.NotAuthenticatedError: When the user is not
authenticated.
:raise pyschlage.exceptions.NotAuthorizedError: When authentication fails.
:raise pyschlage.exceptions.UnknownError: On other errors.
"""
Expand All @@ -248,7 +254,8 @@ def save(self):
def delete(self):
"""Deletes the access code.
:raise pyschlage.exceptions.NotAuthenticatedError: When the user is not authenticated.
:raise pyschlage.exceptions.NotAuthenticatedError: When the user is not
authenticated.
:raise pyschlage.exceptions.NotAuthorizedError: When authentication fails.
:raise pyschlage.exceptions.UnknownError: On other errors.
"""
Expand Down
6 changes: 4 additions & 2 deletions pyschlage/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

from dataclasses import dataclass
from datetime import datetime
from datetime import UTC, datetime
import time

_DEFAULT_UUID = "ffffffff-ffff-ffff-ffff-ffffffffffff"
Expand Down Expand Up @@ -59,7 +59,9 @@
def _utc2local(utc: datetime) -> datetime:
"""Converts a UTC datetime to localtime."""
epoch = time.mktime(utc.timetuple())
offset = datetime.fromtimestamp(epoch) - datetime.utcfromtimestamp(epoch)
offset = datetime.fromtimestamp(epoch) - datetime.fromtimestamp(epoch, UTC).replace(
tzinfo=None
)
return (utc + offset).replace(tzinfo=None)


Expand Down

0 comments on commit a7ecb52

Please sign in to comment.