Skip to content

Commit

Permalink
Merge pull request #281 from thegridelectric/dev
Browse files Browse the repository at this point in the history
Dependency updates, cleanups and python 3.12 support.
 - Adds support for python 3.12.
 - Removed dependency on gridworks and safety, which removes 43 other dependencies. 
 - Update other dependencies.
  • Loading branch information
anschweitzer committed Apr 1, 2024
2 parents 8053882 + 2bd5636 commit 568c730
Show file tree
Hide file tree
Showing 119 changed files with 1,490 additions and 1,938 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pip==23.3.2
nox==2023.4.22
pip==24.0
nox==2024.3.2
nox-poetry==1.0.3
poetry==1.7.1
virtualenv==20.25.0
poetry==1.8.2
virtualenv==20.25.1
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,21 @@ jobs:
- name: Publish package on PyPI
if: steps.check-version.outputs.tag
uses: pypa/[email protected].11
uses: pypa/[email protected].14
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}

- name: Publish package on TestPyPI
if: "! steps.check-version.outputs.tag"
uses: pypa/[email protected].11
uses: pypa/[email protected].14
with:
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/

- name: Publish the release notes
uses: release-drafter/release-drafter@v5.25.0
uses: release-drafter/release-drafter@v6.0.0
with:
publish: ${{ steps.check-version.outputs.tag != '' }}
tag: ${{ steps.check-version.outputs.tag }}
Expand Down
19 changes: 8 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,14 @@ jobs:
fail-fast: false
matrix:
include:
- { python: "3.11", os: "ubuntu-latest", session: "pre-commit" }
# - { python: "3.10", os: "ubuntu-latest", session: "safety" }
# - { python: "3.10", os: "ubuntu-latest", session: "mypy" }
- { python: "3.12", os: "ubuntu-latest", session: "pre-commit" }
# - { python: "3.12", os: "ubuntu-latest", session: "mypy" }
- { python: "3.11", os: "ubuntu-latest", session: "tests" }
- { python: "3.10", os: "ubuntu-latest", session: "tests" }
- { python: "3.11", os: "windows-latest", session: "tests" }
- { python: "3.11", os: "macos-latest", session: "tests" }
# - { python: "3.10", os: "ubuntu-latest", session: "typeguard" }
- { python: "3.11", os: "ubuntu-latest", session: "xdoctest" }
- { python: "3.11", os: "ubuntu-latest", session: "docs-build" }

- { python: "3.12", os: "windows-latest", session: "tests" }
- { python: "3.12", os: "macos-latest", session: "tests" }
- { python: "3.12", os: "ubuntu-latest", session: "xdoctest" }
- { python: "3.12", os: "ubuntu-latest", session: "docs-build" }
env:
NOXSESSION: ${{ matrix.session }}
FORCE_COLOR: "1"
Expand Down Expand Up @@ -114,7 +111,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
python-version: "3.12"

- name: Upgrade pip
run: |
Expand Down Expand Up @@ -146,4 +143,4 @@ jobs:
nox --session=coverage -- xml
- name: Upload coverage report
uses: codecov/codecov-action@v4.0.0
uses: codecov/codecov-action@v4.1.1
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Sphinx configuration."""

project = "Gridworks Protocol"
author = "Jessica Millar"
copyright = "2022, Jessica Millar"
Expand Down
12 changes: 2 additions & 10 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nox sessions."""

import os
import shlex
import shutil
Expand All @@ -24,12 +25,11 @@


package = "gwproto"
python_versions = ["3.11", "3.10"]
python_versions = ["3.12", "3.11", "3.10"]

nox.needs_version = ">= 2021.6.6"
nox.options.sessions = (
"pre-commit",
# "safety",
# "mypy",
"tests",
# "typeguard",
Expand Down Expand Up @@ -140,14 +140,6 @@ def precommit(session: Session) -> None:
activate_virtualenv_in_precommit_hooks(session)


@session(python=python_versions[0])
def safety(session: Session) -> None:
"""Scan dependencies for insecure packages."""
requirements = session.poetry.export_requirements()
session.install("safety")
session.run("safety", "check", "--full-report", f"--file={requirements}")


@session(python=python_versions)
def mypy(session: Session) -> None:
"""Type-check using mypy."""
Expand Down
2,761 changes: 913 additions & 1,848 deletions poetry.lock

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "gridworks-protocol"
version = "0.7.1"
version = "0.7.2"
description = "Gridworks Protocol"
authors = ["Jessica Millar <[email protected]>"]
license = "MIT"
Expand All @@ -19,12 +19,12 @@ classifiers = [
Changelog = "https://github.com/thegridelectric/gridworks-protocol/releases"

[tool.poetry.dependencies]
python = ">=3.10, <4.0"
python = "^3.10"
pydantic = "^1.10.2"
pendulum = "^2.1.2"
fastapi-utils = "^0.2.1"
gridworks = "^0.2.9"
pendulum = "^3"
yarl = "^1.9.2"
pytz = "^2024.1"
fastapi-utils = "^0.2.1"

[tool.poetry.dev-dependencies]
Pygments = ">=2.10.0"
Expand All @@ -44,7 +44,6 @@ pre-commit = ">=2.16.0"
pre-commit-hooks = ">=4.1.0"
pytest = ">=6.2.5"
pyupgrade = ">=2.29.1"
safety = ">=1.10.3"
sphinx = ">=4.3.2"
sphinx-autobuild = ">=2021.3.14"
sphinx-click = ">=3.0.2"
Expand Down
1 change: 1 addition & 0 deletions src/gwproto/data_classes/cacs/electric_meter_cac.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""ElectricMeterCac definition"""

from typing import Dict
from typing import List
from typing import Optional
Expand Down
3 changes: 1 addition & 2 deletions src/gwproto/data_classes/cacs/fibaro_smart_implant_cac.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from gwproto.data_classes.component_attribute_class import ComponentAttributeClass


class FibaroSmartImplantCac(ComponentAttributeClass):
...
class FibaroSmartImplantCac(ComponentAttributeClass): ...
3 changes: 1 addition & 2 deletions src/gwproto/data_classes/cacs/hubitat_cac.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from gwproto.data_classes.component_attribute_class import ComponentAttributeClass


class HubitatCac(ComponentAttributeClass):
...
class HubitatCac(ComponentAttributeClass): ...
3 changes: 1 addition & 2 deletions src/gwproto/data_classes/cacs/hubitat_poller_cac.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from gwproto.data_classes.component_attribute_class import ComponentAttributeClass


class HubitatPollerCac(ComponentAttributeClass):
...
class HubitatPollerCac(ComponentAttributeClass): ...
3 changes: 1 addition & 2 deletions src/gwproto/data_classes/cacs/hubitat_tank_module_cac.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from gwproto.data_classes.component_attribute_class import ComponentAttributeClass


class HubitatTankModuleCac(ComponentAttributeClass):
...
class HubitatTankModuleCac(ComponentAttributeClass): ...
1 change: 1 addition & 0 deletions src/gwproto/data_classes/cacs/multipurpose_sensor_cac.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""MultipurposeSensorCac definition"""

from typing import Dict
from typing import List
from typing import Optional
Expand Down
1 change: 1 addition & 0 deletions src/gwproto/data_classes/cacs/pipe_flow_sensor_cac.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""PipeFlowSensorCac definition"""

from typing import Dict
from typing import Optional

Expand Down
1 change: 1 addition & 0 deletions src/gwproto/data_classes/cacs/relay_cac.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""RelayCac definition"""

from typing import Dict
from typing import Optional

Expand Down
1 change: 1 addition & 0 deletions src/gwproto/data_classes/cacs/resistive_heater_cac.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""ElectricHeaterCac definition"""

from typing import Dict
from typing import Optional

Expand Down
3 changes: 1 addition & 2 deletions src/gwproto/data_classes/cacs/rest_poller_cac.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from gwproto.data_classes.component_attribute_class import ComponentAttributeClass


class RESTPollerCac(ComponentAttributeClass):
...
class RESTPollerCac(ComponentAttributeClass): ...
1 change: 1 addition & 0 deletions src/gwproto/data_classes/cacs/simple_temp_sensor_cac.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""SimpleTempSensorCac definition"""

from typing import Dict
from typing import Optional

Expand Down
1 change: 1 addition & 0 deletions src/gwproto/data_classes/component_attribute_class.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" ComponentAttributeClass"""

from abc import ABC
from typing import Dict
from typing import Optional
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""ElectricMeterComponent definition"""

from typing import Dict
from typing import List
from typing import Optional
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""MutlipurposeSensorComponent definition"""

from typing import Dict
from typing import List
from typing import Optional
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""PipeFlowSensorComponent definition"""

from typing import Dict
from typing import Optional

Expand Down
1 change: 1 addition & 0 deletions src/gwproto/data_classes/components/relay_component.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""RelayComponent definition"""

from typing import Dict
from typing import Optional

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""ResistiveHeaterComponent definition"""

from typing import Dict
from typing import Optional

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""SimpleTempSensorComponent definition"""

from typing import Dict
from typing import Optional

Expand Down
17 changes: 9 additions & 8 deletions src/gwproto/data_classes/hardware_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
because content is static (except for needing a path to the houses.json file, which we should be able to do
away with).
"""

import copy
import json
import re
Expand Down Expand Up @@ -82,10 +83,10 @@ def load_cacs(
]:
for d in layout.get(type_name, []):
try:
cacs[
d["ComponentAttributeClassId"]
] = maker_class.dict_to_dc( # type:ignore[attr-defined]
d
cacs[d["ComponentAttributeClassId"]] = (
maker_class.dict_to_dc( # type:ignore[attr-defined]
d
)
)
except Exception as e:
if raise_errors:
Expand Down Expand Up @@ -129,10 +130,10 @@ def load_components(
]:
for d in layout.get(type_name, []):
try:
components[
d["ComponentId"]
] = maker_class.dict_to_dc( # type:ignore[attr-defined]
d
components[d["ComponentId"]] = (
maker_class.dict_to_dc( # type:ignore[attr-defined]
d
)
)
except Exception as e:
if raise_errors:
Expand Down
1 change: 1 addition & 0 deletions src/gwproto/data_classes/sh_node.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""ShNode definition"""

from typing import Dict
from typing import Optional

Expand Down
6 changes: 2 additions & 4 deletions src/gwproto/decoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ def decode_str(self, content: str | bytes, encoding: str = "utf-8") -> Any:
return self.decode_obj(json.loads(content))

@abstractmethod
def decode_obj(self, o: Any) -> Any:
...
def decode_obj(self, o: Any) -> Any: ...


class CallableDecoder(Decoder):
Expand Down Expand Up @@ -269,8 +268,7 @@ def decode(self, topic: str, payload: bytes) -> Any:
)

@abstractmethod
def validate_source_alias(self, source_alias: str):
...
def validate_source_alias(self, source_alias: str): ...


def get_pydantic_literal_type_name(
Expand Down
26 changes: 22 additions & 4 deletions src/gwproto/errors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
from gridworks.errors import AlgoError
from gridworks.errors import DcError
from gridworks.errors import RegistryError
from gridworks.errors import SchemaError
class SchemaError(Exception):
"""Base class for Schema errors"""

pass


class AlgoError(Exception):
"""Base class for errors related to Algorand"""

pass


class DcError(Exception):
"""Base class for dataclass errors"""

pass


class RegistryError(Exception):
"""Base class for registry errors"""

pass
Loading

0 comments on commit 568c730

Please sign in to comment.