Skip to content

Commit

Permalink
fix(deps): replace monads with pyella
Browse files Browse the repository at this point in the history
The monad sources were migrated to the pyella library, so replace the
sources with said library. Pyella only supports Python >= 3.8 though,
because everything older is ancient, which is why Huemon will make the same change.

BREAKING CHANGE: minimal python version bumped to 3.8
  • Loading branch information
edeckers committed Oct 15, 2022
1 parent a0f7790 commit cedae55
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 548 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Zabbix monitoring with low-level discovery for Philips Hue networks.

- Zabbix server 5.0+
- Zabbix agent 5.0+
- Python 3.7+ on Zabbix agent machine
- Python 3.8+ on Zabbix agent machine

## Installation

Expand Down
173 changes: 67 additions & 106 deletions poetry.lock

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ classifiers = [
"Environment :: Console",
"Operating System :: MacOS",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand Down Expand Up @@ -36,13 +35,15 @@ version = "0.9.2"

[tool.poetry.dependencies]
fastapi = "^0.75.0"
python = "^3.7"
python = "^3.8"
PyYAML = "^6.0"
types-PyYAML = "^6.0.4"
uvicorn = "^0.17.5"
pyella = "^0.1.0"

[tool.poetry.dev-dependencies]
bandit = "^1.7"
black = {version = "^22.6.0", allow-prereleases = true}
coverage = {extras = ["toml"], version = "^6.3.2"}
mypy = "^0.931"
nox = "^2022.1.7"
Expand All @@ -54,7 +55,6 @@ python-semantic-release = "^7.25.2"

#########################################################################################
# Testing
black = {version = "^22.6.0", allow-prereleases = true}
#########################################################################################

[tool.pytest.ini_options]
Expand Down Expand Up @@ -95,7 +95,6 @@ build_command = "poetry build"
commit_subject = "chore: release {version}"
changelog_file = "README.md"
changelog_placeholder = "DISABLE_CHANGELOG_HACK"
major_on_zero = false
version_pattern = [
"assets/release/release-docker.sh:huemon:{version}",
"docker-compose.yml:huemon:{version}",
Expand Down
3 changes: 2 additions & 1 deletion src/huemon/commands/command_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
from functools import reduce
from typing import List, Type

from pyella.either import rights

from huemon.api.api_factory import create_api
from huemon.api.api_interface import ApiInterface
from huemon.commands.hue_command_interface import HueCommand
from huemon.infrastructure.logger_factory import create_logger
from huemon.infrastructure.plugin_loader import load_plugins
from huemon.utils.errors import exit_fail
from huemon.utils.monads.either import rights
from huemon.utils.paths import create_local_path

LOG = create_logger()
Expand Down
5 changes: 3 additions & 2 deletions src/huemon/commands/internal/discover_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
from functools import reduce
from typing import Dict, List, Type

from pyella.either import Either, rights
from pyella.maybe import Maybe, maybe, of

from huemon.api.api_interface import ApiInterface
from huemon.commands.hue_command_interface import HueCommand
from huemon.discoveries.discovery_interface import Discovery
from huemon.infrastructure.logger_factory import create_logger
from huemon.infrastructure.plugin_loader import load_plugins
from huemon.utils.assertions import assert_exists, assert_num_args
from huemon.utils.monads.either import Either, rights
from huemon.utils.monads.maybe import Maybe, maybe, of
from huemon.utils.paths import create_local_path
from huemon.utils.plugins import get_discovery_plugins_path

Expand Down
9 changes: 5 additions & 4 deletions src/huemon/infrastructure/plugin_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
from pathlib import Path
from typing import List, Tuple, Type, TypeVar, cast

from pyella.either import Either, Left, right
from pyella.maybe import Maybe

from huemon.utils.errors import E_CODE_PLUGIN_LOADER, HueError
from huemon.utils.monads.either import Either, Left, right
from huemon.utils.monads.maybe import Maybe

TA = TypeVar("TA")

Expand All @@ -19,8 +20,8 @@ def __error(message: str) -> HueError:
return HueError(E_CODE_PLUGIN_LOADER, message)


def __lerror(message: str) -> Left[HueError, TA]:
return Left[HueError, TA](__error(message))
def __lerror(message: str) -> Left[HueError, Type[TA]]:
return Left(__error(message))


def __get_plugin_type(
Expand Down
4 changes: 0 additions & 4 deletions src/huemon/utils/monads/__init__.py

This file was deleted.

124 changes: 0 additions & 124 deletions src/huemon/utils/monads/either.py

This file was deleted.

88 changes: 0 additions & 88 deletions src/huemon/utils/monads/maybe.py

This file was deleted.

1 change: 0 additions & 1 deletion src/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

def __load_poetry_venv(session):
# https://stackoverflow.com/a/59904246
session.run("poetry", "shell")
session.run("poetry", "install")


Expand Down
Loading

0 comments on commit cedae55

Please sign in to comment.