-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* GitHub codeformat & linting action Add requirements.txt and test-requirements.txt * Reformat code, organize imports * Use Enum, add docstrings, linting issues * Backward compatible refactoring Fix invalid names in non-public methods. Fix linting issues. Add docstrings. * Fix Enum classes, entity storage iteration Make Enum classes work again with json.dump: must inherit from str. Prepare pyproject.toml Fix license in setup.py
- Loading branch information
Showing
21 changed files
with
1,047 additions
and
426 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Check Python code formatting | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'ucapi/**' | ||
- 'requirements.txt' | ||
- 'test-requirements.txt' | ||
- 'tests/**' | ||
- '.github/**/*.yml' | ||
- '.pylintrc' | ||
- 'pyproject.toml' | ||
- 'tox.ini' | ||
pull_request: | ||
branches: [main] | ||
types: [opened, synchronize, reopened] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-22.04 | ||
|
||
name: Check Python code formatting | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.11" | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
if [ -f test-requirements.txt ]; then pip install -r test-requirements.txt; fi | ||
- name: Analyzing the code with pylint | ||
run: | | ||
python -m pylint ucapi | ||
- name: Lint with flake8 | ||
run: | | ||
python -m flake8 ucapi --count --show-source --statistics | ||
- name: Check code formatting with isort | ||
run: | | ||
python -m isort ucapi/. --check --verbose | ||
- name: Check code formatting with black | ||
run: | | ||
python -m black ucapi --check --verbose --line-length 120 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,102 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*,cover | ||
.hypothesis/ | ||
.pylint.d/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# IPython Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# dotenv | ||
.env | ||
|
||
# virtualenv | ||
venv/ | ||
ENV/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# Local development settings | ||
.settings/ | ||
.project | ||
.pydevproject | ||
.pypirc | ||
.pytest_cache | ||
|
||
# Visual Studio Code | ||
.vscode/ | ||
|
||
.DS_Store | ||
.vscode/settings.json | ||
build | ||
dist | ||
*.egg-info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
[MAIN] | ||
# Specify a score threshold to be exceeded before program exits with error. | ||
fail-under=9.5 | ||
|
||
# Return non-zero exit code if any of these messages/categories are detected, | ||
# even if score is above --fail-under value. Syntax same as enable. Messages | ||
# specified are enabled, while categories only check already-enabled messages. | ||
fail-on= | ||
logging-fstring-interpolation, | ||
logging-not-lazy, | ||
unspecified-encoding, | ||
consider-using-from-import, | ||
consider-using-with, | ||
invalid-name | ||
|
||
[FORMAT] | ||
|
||
# Maximum number of characters on a single line. | ||
max-line-length=120 | ||
|
||
[MESSAGES CONTROL] | ||
|
||
# Disable the message, report, category or checker with the given id(s). You | ||
# can either give multiple identifiers separated by comma (,) or put this | ||
# option multiple times (only on the command line, not in the configuration | ||
# file where it should appear only once).You can also use "--disable=all" to | ||
# disable everything first and then re-enable specific checks. For example, if | ||
# you want to run only the similarities checker, you can use "--disable=all | ||
# --enable=similarities". If you want to run only the classes checker, but have | ||
# no Warning level messages displayed, use"--disable=all --enable=classes | ||
# --disable=W" | ||
|
||
disable= | ||
too-many-instance-attributes, | ||
global-statement, | ||
too-many-arguments, | ||
unused-argument, | ||
too-few-public-methods | ||
|
||
[STRING] | ||
|
||
# This flag controls whether inconsistent-quotes generates a warning when the | ||
# character used as a quote delimiter is used inconsistently within a module. | ||
check-quote-consistency=yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# TODO migrate from setup.py: this is work in progress | ||
[build-system] | ||
requires = ["setuptools>=61.2"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "ucapi" | ||
version = "0.0.11" | ||
authors = [ | ||
{name = "Unfolded Circle ApS", email = "[email protected]"} | ||
] | ||
license = {text = "MPL-2.0"} | ||
description = "Python wrapper for the Unfolded Circle Integration API" | ||
classifiers = [ | ||
"Development Status :: 2 - Pre-Alpha", | ||
"Intended Audience :: Developers", | ||
"License :: OSI Approved :: MPL-2.0 License", | ||
"Operating System :: OS Independent", | ||
"Topic :: Software Development :: Libraries", | ||
"Topic :: Home Automation", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
] | ||
requires-python = ">=3.10" | ||
dependencies = [ | ||
"asyncio==3.4.3", | ||
"pyee==9.0.4", | ||
"websockets==11.0.3", | ||
"zeroconf==0.119.0", | ||
] | ||
|
||
[project.readme] | ||
file = "README.md" | ||
content-type = "text/markdown; charset=UTF-8" | ||
|
||
[project.optional-dependencies] | ||
testing = [ | ||
"pylint", | ||
"flake8-docstrings", | ||
"flake8", | ||
"black", | ||
"isort", | ||
] | ||
|
||
[tool.setuptools] | ||
zip-safe = false | ||
platforms = ["any"] | ||
license-files = ["LICENSE"] | ||
# TODO is this correct? Set to True in old setup.py | ||
include-package-data = true | ||
|
||
[tool.setuptools.packages.find] | ||
exclude = ["tests"] | ||
namespaces = false | ||
|
||
[tool.isort] | ||
profile = "black" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
asyncio==3.4.3 | ||
pyee==9.0.4 | ||
websockets==11.0.3 | ||
zeroconf==0.119.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
# TODO remove and use pyproject.toml: https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html | ||
|
||
from setuptools import setup, find_packages | ||
|
||
from codecs import open | ||
from os import path | ||
|
||
PACKAGE_NAME = 'ucapi' | ||
PACKAGE_NAME = "ucapi" | ||
HERE = path.abspath(path.dirname(__file__)) | ||
VERSION = '0.0.10' | ||
VERSION = "0.0.11" | ||
|
||
with open(path.join(HERE, 'README.md'), encoding='utf-8') as f: | ||
with open(path.join(HERE, "README.md"), encoding="utf-8") as f: | ||
long_description = f.read() | ||
|
||
setup( | ||
|
@@ -17,8 +19,8 @@ | |
url="https://unfoldedcircle.com", | ||
author="Unfolded Circle ApS", | ||
author_email="[email protected]", | ||
license="MIT", | ||
packages=['ucapi'], | ||
license="MPL-2.0", | ||
packages=["ucapi"], | ||
include_package_data=True, | ||
install_requires=find_packages() | ||
) | ||
install_requires=find_packages(), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pylint | ||
flake8-docstrings | ||
flake8 | ||
black | ||
isort |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
[flake8] | ||
max_line_length = 120 | ||
|
||
[tox] | ||
envlist = py310,py311,pylint,lint,format | ||
skip_missing_interpreters = True | ||
|
||
[testenv:format] | ||
basepython = python3.11 | ||
deps = | ||
-r{toxinidir}/test-requirements.txt | ||
commands = | ||
python -m isort ucapi/. --check --verbose | ||
python -m black ucapi --check --verbose | ||
|
||
[testenv:pylint] | ||
basepython = python3.11 | ||
deps = | ||
-r{toxinidir}/test-requirements.txt | ||
commands=python -m pylint ucapi | ||
|
||
[testenv:lint] | ||
basepython = python3.11 | ||
deps = | ||
-r{toxinidir}/test-requirements.txt | ||
commands = | ||
python -m flake8 ucapi | ||
; python -m pydocstyle ucapi | ||
|
||
;[testenv] | ||
;setenv = | ||
; LANG=en_US.UTF-8 | ||
; PYTHONPATH = {toxinidir} | ||
;deps = | ||
; -r{toxinidir}/test-requirements.txt | ||
;commands=python -m pytest tests --timeout=30 --durations=10 --cov=denonavr --cov-report html {posargs} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Integration driver library for Remote Two. | ||
:copyright: (c) 2023 by Unfolded Circle ApS. | ||
:license: MPL 2.0, see LICENSE for more details. | ||
""" |
Oops, something went wrong.