Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to pyproject toml #19

Merged
merged 5 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install flake8
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements_dev.txt ]; then pip install -r requirements_dev.txt; fi
if [ -f requirements_test.txt ]; then pip install -r requirements_test.txt; fi
pip install . .[test]
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install build twine
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python setup.py sdist bdist_wheel
python -m build
twine upload dist/*
9 changes: 0 additions & 9 deletions MANIFEST.in

This file was deleted.

43 changes: 43 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[build-system]
requires = ["setuptools>=62.3"]
build-backend = "setuptools.build_meta"

[tool.setuptools.package-data]
ynca = ["py.typed"]

[tool.setuptools.packages.find]
include = ["ynca*"]


[project]
name = "ynca"
version = "5.16.0"
description = "Package to control Yamaha receivers that support the YNCA protocol."
readme = "README.md"
requires-python = ">=3.8"
authors = [
{ name = "Michel van de Wetering", email = "[email protected]" },
]
license = {file = "LICENSE.txt"}
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Topic :: Home Automation",
"Topic :: Software Development :: Libraries",
]
dependencies = ["pyserial>=3.4,<4"]

urls = { Homepage = "https://github.com/mvdwetering/ynca" }

[project.optional-dependencies]
test = [
"mypy==1.11.0",
"ruff==0.5.5",
"pytest>=7.0.0",
"pytest-mock",
"pytest-cov",
"mock-serial==0.0.1",
]
1 change: 0 additions & 1 deletion requirements.txt

This file was deleted.

2 changes: 0 additions & 2 deletions requirements_dev.txt

This file was deleted.

5 changes: 0 additions & 5 deletions requirements_test.txt

This file was deleted.

5 changes: 0 additions & 5 deletions setup.cfg

This file was deleted.

97 changes: 0 additions & 97 deletions setup.py

This file was deleted.

4 changes: 2 additions & 2 deletions tests/test_subunit.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Test Zone subunit"""

from unittest import mock
import pytest
import pytest # type: ignore[import]

from ynca import Avail
from ynca.constants import Subunit
Expand Down Expand Up @@ -155,6 +155,6 @@ class descriptor:
def __get__(self, instance, owner):
raise AttributeError("unreadable attribute")

DummySubunit.__provides__ = descriptor()
DummySubunit.__provides__ = descriptor() # type: ignore
DummySubunit(connection)

4 changes: 2 additions & 2 deletions tests/test_tun.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pytest
import pytest # type: ignore[import]

from ynca import BandTun
from ynca.subunits.tun import Tun
Expand Down Expand Up @@ -121,7 +121,7 @@ def test_preset(connection, initialized_tun: Tun):
assert initialized_tun.preset == 11

connection.send_protocol_message(SUBUNIT, "PRESET", "No Preset")
assert initialized_tun.preset == None
assert initialized_tun.preset is None

# Set preset
initialized_tun.preset = 10
Expand Down
38 changes: 38 additions & 0 deletions ynca/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,42 @@
)
from .modelinfo import YncaModelInfo

__all__ = [
"YncaApi",
"YncaConnectionCheckResult",
"YncaConnection",
"YncaProtocolStatus",
"YncaException",
"YncaConnectionError",
"YncaConnectionFailed",
"YncaInitializationFailedException",
"YncaModelInfo",
"Avail",
"AdaptiveDrc",
"BandDab",
"BandTun",
"DabPreset",
"Enhancer",
"FmPreset",
"HdmiOut",
"HdmiOutOnOff",
"InitVolLvl",
"InitVolMode",
"Input",
"Mute",
"Party",
"PartyMute",
"Playback",
"PlaybackInfo",
"PureDirMode",
"Pwr",
"Repeat",
"Shuffle",
"Sleep",
"SoundPrg",
"Straight",
"ThreeDeeCinema",
"TwoChDecoder",
]

logging.getLogger(__name__).addHandler(logging.NullHandler())
4 changes: 2 additions & 2 deletions ynca/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def _detect_available_subunits(self, connection: YncaConnection):
2 + (num_commands_sent * (YncaProtocol.COMMAND_SPACING * 5))
):
raise YncaInitializationFailedException(
f"Subunit availability check failed"
"Subunit availability check failed"
)

connection.unregister_message_callback(self._protocol_message_received)
Expand Down Expand Up @@ -179,7 +179,7 @@ def initialize(self):
If initialize was successful the client should call the `close()`
method when done with the Ynca API object to cleanup.
"""
assert self._connection == None, "Can only initialize once!"
assert self._connection is None, "Can only initialize once!"

is_initialized = False

Expand Down
4 changes: 2 additions & 2 deletions ynca/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ def to_value(self, value_string: str) -> Any:
for converter in self._converters:
try:
return converter.to_value(value_string)
except:
except: # noqa: E722
pass
raise ValueError(f"No converter could convert '{value_string}' to value")

def to_str(self, value: Any) -> str:
for converter in self._converters:
try:
return converter.to_str(value)
except:
except: # noqa: E722
pass
raise ValueError(f"No converter could convert {value} to string")
2 changes: 1 addition & 1 deletion ynca/subunit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import logging
import threading
from abc import ABC, abstractmethod
from abc import ABC
from enum import Flag, auto
from typing import Any, Callable, Dict, Set

Expand Down
2 changes: 0 additions & 2 deletions ynca/subunits/dab.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from __future__ import annotations

from ..constants import Subunit
from ..converters import IntOrNoneConverter
from ..enums import BandDab, DabPreset, FmPreset
from ..function import (
Cmd,
EnumFunctionMixin,
EnumOrIntFunctionMixin,
IntFunctionMixin,
StrFunctionMixin,
)
from ..subunit import SubunitBase
Expand Down
1 change: 0 additions & 1 deletion ynca/terminal.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
import logging
import re
import sys

Expand Down