From 5e7bd9ac2b750a278e96100a0469901abc05ef84 Mon Sep 17 00:00:00 2001 From: Maja Massarini Date: Tue, 8 Nov 2022 11:55:22 +0100 Subject: [PATCH 1/2] Add pre-commit hook and vm_image_builder job --- .flake8 | 2 +- .github/workflows/build.yml | 61 +- .packit.yaml | 33 +- .pre-commit-config.yaml | 59 + CHANGELOG.txt | 2 +- README.md | 7 +- daemon/Makefile | 2 +- docs/source/addresses.rst | 1 - docs/source/conf.py | 29 +- docs/source/datapointtypes.rst | 1 - docs/source/index.html | 1155 ++++++++++------- docs/source/intro.rst | 1 - docs/source/services.rst | 1 - docs/source/tables.rst | 2 - knx_stack/client/usbhid.py | 2 +- knx_stack/datapointtypes.py | 26 +- knx_stack/definition/knxnet_ip/state.py | 2 +- knx_stack/definition/layer/link/ldata.py | 2 +- .../definition/layer/network/address_table.py | 2 +- .../layer/transport/association_table.py | 2 +- knx_stack/state.py | 14 +- .../tests/test_on_field_a_property_value.py | 42 +- python-knx-stack.spec | 2 +- setup.py | 45 +- 24 files changed, 894 insertions(+), 601 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.flake8 b/.flake8 index 3c92c12..f6c9cdd 100644 --- a/.flake8 +++ b/.flake8 @@ -13,4 +13,4 @@ extend-ignore = W503,E203,E501,W505 max-line-length = 88 max-doc-length = 120 -per-file-ignores = __init__.py:F401,E402 \ No newline at end of file +per-file-ignores = __init__.py:F401,E402 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6ef65ce..ed05b36 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,41 +2,40 @@ name: knx-stack on: push: - branches: [ kickoff ] + branches: [kickoff] pull_request: - branches: [ kickoff ] + branches: [kickoff] jobs: build: - runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.8 - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest coverage - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - python setup.py install - # - name: Lint with flake8 - # run: | - # stop the build if there are Python syntax errors or undefined names - # flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - # flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test and Coverage - run: | - python -m coverage run - python -m coverage report - - name: Build egg - run: | - python setup.py bdist_egg - - name: Upload a Build Artifact - uses: actions/upload-artifact@v2.1.4 - with: - path: dist/* + - uses: actions/checkout@v2 + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest coverage + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + python setup.py install + # - name: Lint with flake8 + # run: | + # stop the build if there are Python syntax errors or undefined names + # flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + # flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test and Coverage + run: | + python -m coverage run + python -m coverage report + - name: Build egg + run: | + python setup.py bdist_egg + - name: Upload a Build Artifact + uses: actions/upload-artifact@v2.1.4 + with: + path: dist/* diff --git a/.packit.yaml b/.packit.yaml index 9c61825..a17c24f 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -1,13 +1,15 @@ # See the documentation for more information: # https://packit.dev/docs/configuration/ -packit_instances: ["stg", ] +packit_instances: ["stg"] specfile_path: python-knx-stack.spec # add or remove files that should be synced synced_files: - - python-knx-stack.spec - - .packit.yaml + - python-knx-stack.spec + - .packit.yaml + +#release_suffix: "" # name in upstream package repository or registry (e.g. in PyPI) upstream_package_name: knx-stack @@ -18,15 +20,28 @@ upstream_project_url: https://github.com/majamassarini/knx-stack issue_repository: https://github.com/majamassarini/knx-stack jobs: -- job: copr_build - trigger: pull_request - metadata: + - job: copr_build + trigger: pull_request targets: fedora-stable owner: mmassari project: knx-stack -- job: copr_build - trigger: commit - metadata: + - job: copr_build + trigger: commit targets: fedora-stable owner: mmassari project: knx-stack + - job: vm_image_build + trigger: pull_request + copr_chroot: fedora-36-x86_64 + owner: mmassari + project: knx-stack + image_customizations: + packages: [python-knx-stack] + image_distribution: fedora-36 + image_request: + architecture: x86_64 + image_type: aws + upload_request: + type: aws + options: + share_with_accounts: ["727920394381"] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..d8ee747 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,59 @@ +# HOWTO: https://pre-commit.com/#usage +# pip3 install pre-commit +# pre-commit install -t pre-commit -t pre-push + +repos: + - repo: https://github.com/asottile/pyupgrade + rev: v3.1.0 + hooks: + - id: pyupgrade + - repo: https://github.com/psf/black + rev: 22.10.0 + hooks: + - id: black + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v3.0.0-alpha.3 + hooks: + - id: prettier + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 + hooks: + - id: check-added-large-files + - id: check-ast + #- id: check-builtin-literals + - id: check-docstring-first + - id: check-executables-have-shebangs + - id: check-merge-conflict + - id: check-symlinks + - id: check-yaml + - id: detect-private-key + - id: end-of-file-fixer + - id: mixed-line-ending + - id: trailing-whitespace + - repo: https://github.com/PyCQA/flake8 + rev: 5.0.4 + hooks: + - id: flake8 + args: + - --ignore=F821,BLK100 + # line break before binary operator - introduced by black (W503) + # E203 whitespace before ':' - introduced by black (E203) + # doctests are not well formatted, lines are too long and are not fixed by black, ignore them (W501) + # W505 doc line too long - doctests results are too long end exceed doc line length, ignore them (W505) + - --extend-ignore=W503,E203,E501,W505 + # black setting is 88 + - --max-line-length=88 + - --max-doc-length=120 + - --per-file-ignores=__init__.py:F401,E402 + # - repo: https://github.com/PyCQA/isort + # rev: 5.10.1 + # hooks: + # - id: isort + # args: [--profile, black] + #- repo: https://github.com/pre-commit/mirrors-mypy + # rev: v0.982 + # hooks: + # - id: mypy + # args: [--show-error-codes, --ignore-missing-imports] + # additional_dependencies: + # [types-pkg_resources, types-requests, types-python-dateutil] diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 7af843b..4409efd 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -2,4 +2,4 @@ Change Log ---------- Version 0.9.2 Sun Feb 6 2022 - - first public release \ No newline at end of file + - first public release diff --git a/README.md b/README.md index bcd31a0..2b349df 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,14 @@ A Python 3 KNX stack, not complete but easily extensible. -It is able to *encode/decode* knx messages for both **USB HID** and **KNXnet IP**. +It is able to _encode/decode_ knx messages for both **USB HID** and **KNXnet IP**. It can be used with an **asynchronous** or **synchronous** client. ## Examples -### Setup +### Setup + ```python >>> import knx_stack >>> individual_address = knx_stack.Address(0x0001) @@ -137,7 +138,6 @@ It can be used with an **asynchronous** or **synchronous** client. ('DPT_Switch', {'action': 'off'}) ``` - ## Installation ``` @@ -155,4 +155,3 @@ Pull requests are welcome. ## License knx-stack is licensed under the MIT license. - diff --git a/daemon/Makefile b/daemon/Makefile index bd963f3..db12375 100644 --- a/daemon/Makefile +++ b/daemon/Makefile @@ -3,7 +3,7 @@ SOURCE=usbhid.c all: $(TARGET) -clean: +clean: rm -f knxstack-usbhid-daemon $(TARGET) : $(SOURCE) diff --git a/docs/source/addresses.rst b/docs/source/addresses.rst index a3c3051..75167f4 100644 --- a/docs/source/addresses.rst +++ b/docs/source/addresses.rst @@ -20,4 +20,3 @@ ThreeLevelStyle --------------- .. autoclass:: knx_stack.address.ThreeLevelStyle - diff --git a/docs/source/conf.py b/docs/source/conf.py index 2c7591d..9f6f084 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -12,18 +12,19 @@ import os import sys -sys.path.insert(0, os.path.abspath('../../')) -print(os.path.abspath('../../')) + +sys.path.insert(0, os.path.abspath("../../")) +print(os.path.abspath("../../")) # -- Project information ----------------------------------------------------- -project = 'knx-stack' -copyright = '2021, Maja Massarini' -author = 'Maja Massarini' +project = "knx-stack" +copyright = "2021, Maja Massarini" +author = "Maja Massarini" # The full version, including alpha/beta/rc tags -release = '0.9' +release = "0.9" # -- General configuration --------------------------------------------------- @@ -32,18 +33,18 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinx.ext.doctest', - 'sphinx.ext.autodoc', + "sphinx.ext.doctest", + "sphinx.ext.autodoc", ] autodoc_inherit_docstrings = True autodoc_default_options = { - 'member-order': 'bysource', - 'members': True, - 'undoc-members': True, + "member-order": "bysource", + "members": True, + "undoc-members": True, } # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. @@ -56,10 +57,10 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = 'sphinx_rtd_theme' +html_theme = "sphinx_rtd_theme" # html_theme = 'nature' # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] \ No newline at end of file +html_static_path = ["_static"] diff --git a/docs/source/datapointtypes.rst b/docs/source/datapointtypes.rst index 15e84d6..584d13f 100644 --- a/docs/source/datapointtypes.rst +++ b/docs/source/datapointtypes.rst @@ -62,4 +62,3 @@ Description Factory ^^^^^^^^^^^^^^^^^^^^^^ .. autoclass:: knx_stack.datapointtypes.DPT_Value_Power - diff --git a/docs/source/index.html b/docs/source/index.html index f6e0063..6344622 100644 --- a/docs/source/index.html +++ b/docs/source/index.html @@ -1,13 +1,15 @@ - - - -index.rst - - - -
- - - -
-

Welcome to knx-stack's documentation!

-
-

System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 9)

-

Unknown directive type "toctree".

-
+      
+

Welcome to knx-stack's documentation!

+
+

+ System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 9) +

+

Unknown directive type "toctree".

+
 .. toctree::
    :maxdepth: 2
    :caption: Contents:
 
-
-
-
-

System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 13)

-

Unknown directive type "autoclass".

-
+
+
+
+

+ System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 13) +

+

Unknown directive type "autoclass".

+
 .. autoclass:: knx_stack.Msg
 
-
-
-
-

System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 15)

-

Unknown directive type "autoclass".

-
+
+
+
+

+ System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 15) +

+

Unknown directive type "autoclass".

+
 .. autoclass:: knx_stack.Address
 
-
-
-
-

System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 17)

-

Unknown directive type "autoclass".

-
+
+
+
+

+ System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 17) +

+

Unknown directive type "autoclass".

+
 .. autoclass:: knx_stack.GroupAddress
 
-
-
-
-

System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 19)

-

Unknown directive type "autoclass".

-
+
+
+
+

+ System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 19) +

+

Unknown directive type "autoclass".

+
 .. autoclass:: knx_stack.address.TwoLevelStyle
 
-
-
-
-

System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 21)

-

Unknown directive type "autoclass".

-
+
+
+
+

+ System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 21) +

+

Unknown directive type "autoclass".

+
 .. autoclass:: knx_stack.address.ThreeLevelStyle
 
-
-
-
-

System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 23)

-

Unknown directive type "autoclass".

-
+
+
+
+

+ System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 23) +

+

Unknown directive type "autoclass".

+
 .. autoclass:: knx_stack.msg.Octect
 
-
-
-
-

System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 25)

-

Unknown directive type "autoclass".

-
+
+
+
+

+ System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 25) +

+

Unknown directive type "autoclass".

+
 .. autoclass:: knx_stack.msg.Short
 
-
-
-
-

System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 27)

-

Unknown directive type "autoclass".

-
+
+
+
+

+ System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 27) +

+

Unknown directive type "autoclass".

+
 .. autoclass:: knx_stack.msg.Long
 
-
-
-
-

System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 29)

-

Unknown directive type "autoclass".

-
+
+
+
+

+ System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 29) +

+

Unknown directive type "autoclass".

+
 .. autoclass:: knx_stack.AddressTable
 
-
-
-
-

System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 31)

-

Unknown directive type "autoclass".

-
+
+
+
+

+ System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 31) +

+

Unknown directive type "autoclass".

+
 .. autoclass:: knx_stack.ASAP
 
-
-
-
-

System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 33)

-

Unknown directive type "autoclass".

-
+
+
+
+

+ System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 33) +

+

Unknown directive type "autoclass".

+
 .. autoclass:: knx_stack.AssociationTable
 
-
-
-
-

System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 35)

-

Unknown directive type "autoclass".

-
+
+
+
+

+ System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 35) +

+

Unknown directive type "autoclass".

+
 .. autoclass:: knx_stack.GroupObjectTable
 
 
-
-
-
-

System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 38)

-

Unknown directive type "testsetup".

-
+
+
+
+

+ System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 38) +

+

Unknown directive type "testsetup".

+
 .. testsetup:: *
 
     import knx_stack
 
-
-
-
-

System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 42)

-

Unknown directive type "doctest".

-
+
+
+
+

+ System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 42) +

+

Unknown directive type "doctest".

+
 .. doctest::
 
     >>> address_table = knx_stack.AddressTable(knx_stack.Address(0x0001), [], 255)
@@ -516,35 +727,63 @@ 

Welcome to knx-stack's documentation!

-
-
- -
-
-

Indices and tables

-
    -
  • :ref:`genindex`

    -
    -

    System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 77); backlink

    -

    Unknown interpreted text role "ref".

    -
    -
  • -
  • :ref:`modindex`

    -
    -

    System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 78); backlink

    -

    Unknown interpreted text role "ref".

    -
    -
  • -
  • :ref:`search`

    -
    -

    System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 79); backlink

    -

    Unknown interpreted text role "ref".

    -
    -
  • -
-
-
- +
+
+

Indices and tables

+
    +
  • +

    + :ref:`genindex` +

    +
    +

    + System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 77); backlink +

    +

    Unknown interpreted text role "ref".

    +
    +
  • +
  • +

    + :ref:`modindex` +

    +
    +

    + System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 78); backlink +

    +

    Unknown interpreted text role "ref".

    +
    +
  • +
  • +

    + :ref:`search` +

    +
    +

    + System Message: ERROR/3 (/Users/majamassarini/PycharmProjects/knx-stack/docs/source/index.rst, line 79); backlink +

    +

    Unknown interpreted text role "ref".

    +
    +
  • +
+
+
+ diff --git a/docs/source/intro.rst b/docs/source/intro.rst index d32e3c8..debd7ba 100644 --- a/docs/source/intro.rst +++ b/docs/source/intro.rst @@ -166,4 +166,3 @@ Decode to a dictionary >>> factory = knx_stack.datapointtypes.Description_Factory() >>> factory.make(msgs[0].dpt) ('DPT_Switch', {'action': 'off'}) - diff --git a/docs/source/services.rst b/docs/source/services.rst index 598fe7d..c978498 100644 --- a/docs/source/services.rst +++ b/docs/source/services.rst @@ -39,4 +39,3 @@ Encode to bus messages .. automodule:: knx_stack.encode.layer.application.a_property_value_read.req .. automodule:: knx_stack.encode.layer.application.a_property_value_write.req - diff --git a/docs/source/tables.rst b/docs/source/tables.rst index 0bf5eb3..487a0f0 100644 --- a/docs/source/tables.rst +++ b/docs/source/tables.rst @@ -20,5 +20,3 @@ GroupObjectTable ---------------- .. autoclass:: knx_stack.GroupObjectTable - - diff --git a/knx_stack/client/usbhid.py b/knx_stack/client/usbhid.py index 5d7e748..365828b 100644 --- a/knx_stack/client/usbhid.py +++ b/knx_stack/client/usbhid.py @@ -4,7 +4,7 @@ from typing import Iterable, NamedTuple -class Client(object): +class Client: """ *A minimal asynchronous USB HID KNX Client*. diff --git a/knx_stack/datapointtypes.py b/knx_stack/datapointtypes.py index 431c7c1..5724798 100644 --- a/knx_stack/datapointtypes.py +++ b/knx_stack/datapointtypes.py @@ -5,7 +5,7 @@ import decimal -class DPT_Factory(object): +class DPT_Factory: @staticmethod def make(dpt: str, fields_values: dict) -> "knx_stack.datapointtypes.DPT": """ @@ -40,7 +40,7 @@ def make(dpt: str, fields_values: dict) -> "knx_stack.datapointtypes.DPT": return dpt -class Description_Factory(object): +class Description_Factory: @staticmethod def make(dpt): """ @@ -65,16 +65,10 @@ def make(dpt): ('DPT_Value_Lux', {'decoded_value': 9999.36}) """ description = {} - fields = set( - [ - name - for name, _ in inspect.getmembers( - dpt.__class__, inspect.isdatadescriptor - ) - ] - ) - set( - ["bits", "value", "__weakref__", "_b_base_", "_b_needsfree_", "_objects"] - ) + fields = { + name + for name, _ in inspect.getmembers(dpt.__class__, inspect.isdatadescriptor) + } - {"bits", "value", "__weakref__", "_b_base_", "_b_needsfree_", "_objects"} for name in fields: field = dpt.__getattribute__(name) if isinstance(field, IntEnum): @@ -88,7 +82,7 @@ def make(dpt): return dpt.__class__.__name__, description -class DPT(object): +class DPT: """ An abstract KNX DPT """ @@ -584,8 +578,8 @@ def temperatura(self): @temperatura.setter def temperatura(self, value): - self.bits.temperatura_msb = int((value * 10)) >> 8 - self.bits.temperatura_lsb = int((value * 10)) + self.bits.temperatura_msb = int(value * 10) >> 8 + self.bits.temperatura_lsb = int(value * 10) _fields_ = [("bits", _DPTInfoClimaReport), ("value", c_uint32)] @@ -664,7 +658,7 @@ def decode(self): if self.bits.sign == 1 else self.twos_comp(self.bits.mantissa, 11) ) - decoded_data = self.bits.sign * (0.01 * mantissa) * (2 ** self.bits.exponent) + decoded_data = self.bits.sign * (0.01 * mantissa) * (2**self.bits.exponent) return decoded_data def encode(self, value): diff --git a/knx_stack/definition/knxnet_ip/state.py b/knx_stack/definition/knxnet_ip/state.py index e59b809..3a325bf 100644 --- a/knx_stack/definition/knxnet_ip/state.py +++ b/knx_stack/definition/knxnet_ip/state.py @@ -3,7 +3,7 @@ class State(knx_stack.state.State): def __init__(self, medium, association_table=None, datapointtypes=None): - super(State, self).__init__(medium, association_table, datapointtypes) + super().__init__(medium, association_table, datapointtypes) self._communication_channel_id = 0 @property diff --git a/knx_stack/definition/layer/link/ldata.py b/knx_stack/definition/layer/link/ldata.py index f236f25..6a6996e 100644 --- a/knx_stack/definition/layer/link/ldata.py +++ b/knx_stack/definition/layer/link/ldata.py @@ -129,7 +129,7 @@ class L_Data(LittleEndianStructure): """ def __init__(self, *args, **kwargs): - super(L_Data, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self._make_default() def _make_default(self): diff --git a/knx_stack/definition/layer/network/address_table.py b/knx_stack/definition/layer/network/address_table.py index c6454e4..b402484 100644 --- a/knx_stack/definition/layer/network/address_table.py +++ b/knx_stack/definition/layer/network/address_table.py @@ -5,7 +5,7 @@ class AddressTableException(Exception): """Max entries already written inside address table""" -class AddressTable(object): +class AddressTable: """ **4.9 Group Address Table (GrAT)** diff --git a/knx_stack/definition/layer/transport/association_table.py b/knx_stack/definition/layer/transport/association_table.py index f032882..0a2d12b 100644 --- a/knx_stack/definition/layer/transport/association_table.py +++ b/knx_stack/definition/layer/transport/association_table.py @@ -53,7 +53,7 @@ def __hash__(self): return self.value -class AssociationTable(object): +class AssociationTable: """ **4.10 Group Object Association Table (GrOAT)** diff --git a/knx_stack/state.py b/knx_stack/state.py index c4fbb98..f999a4c 100644 --- a/knx_stack/state.py +++ b/knx_stack/state.py @@ -73,13 +73,13 @@ def __init__( self._sequence_counter_local = 0 def __repr__(self, *args, **kwargs): - s = """ State for %s\n - %s\n - %s\n - LData structure (for decode functions): %s\n - ASAP: %s, APCI: %s, Address Type: %s\n - Sequence Counter (remote): %s\n - Sequence Counter (local): %s\n""" % ( + s = """ State for {}\n + {}\n + {}\n + LData structure (for decode functions): {}\n + ASAP: {}, APCI: {}, Address Type: {}\n + Sequence Counter (remote): {}\n + Sequence Counter (local): {}\n""".format( self.medium, self.association_table, self.datapointtypes, diff --git a/knx_stack/tests/test_on_field_a_property_value.py b/knx_stack/tests/test_on_field_a_property_value.py index 5f02a27..6aed9a2 100644 --- a/knx_stack/tests/test_on_field_a_property_value.py +++ b/knx_stack/tests/test_on_field_a_property_value.py @@ -20,37 +20,31 @@ msgs = list() for i in (0x66, 0x67, 0x68): msgs.append( - ( - knx_stack.encode.layer.application.a_property_value_read.req.Msg( - asap=0, - object_index=0, - property_id=i, - number_of_elements=1, - start_index=0x24, - ) + knx_stack.encode.layer.application.a_property_value_read.req.Msg( + asap=0, + object_index=0, + property_id=i, + number_of_elements=1, + start_index=0x24, ) ) # adjustable misuratore for i in (0x79, 0x7A, 0x7B): msgs.append( - ( - knx_stack.encode.layer.application.a_property_value_read.req.Msg( - asap=0, - object_index=0, - property_id=i, - number_of_elements=1, - start_index=0x13, - ) + knx_stack.encode.layer.application.a_property_value_read.req.Msg( + asap=0, + object_index=0, + property_id=i, + number_of_elements=1, + start_index=0x13, ) ) # adjustable linea msgs.append( - ( - knx_stack.encode.layer.application.a_property_value_read.req.Msg( - asap=0, - object_index=0, - property_id=i, - number_of_elements=1, - start_index=0x11, - ) + knx_stack.encode.layer.application.a_property_value_read.req.Msg( + asap=0, + object_index=0, + property_id=i, + number_of_elements=1, + start_index=0x11, ) ) # misura tipo linea msgs.append(knx_stack.layer.application.a_group_value_read.req.Msg(asap=1)) diff --git a/python-knx-stack.spec b/python-knx-stack.spec index d421057..3351f72 100644 --- a/python-knx-stack.spec +++ b/python-knx-stack.spec @@ -49,4 +49,4 @@ Summary: %{summary} %{python3_sitelib}/knx_stack %changelog -%autochangelog \ No newline at end of file +%autochangelog diff --git a/setup.py b/setup.py index ae29b01..5ba9474 100644 --- a/setup.py +++ b/setup.py @@ -2,28 +2,27 @@ from setuptools import setup, find_packages long_description = "" -with open(path.join(".", 'README.md'), encoding='utf-8') as f: +with open(path.join(".", "README.md"), encoding="utf-8") as f: long_description = f.read() -setup(name="knx-stack", - version="0.9.2", - description="A python3 KNX stack for USB HID and KNXnet IP", - url="https://github.com/majamassarini/knx-stack", - long_description=long_description, - long_description_content_type='text/markdown', - author="Maja Massarini", - author_email="maja.massarini@gmail.com", - license="MIT", - classifiers=[ - "Development Status :: 3 - Alpha", - "License :: OSI Approved :: MIT License", - "Operating System :: POSIX :: Linux", - "Programming Language :: Python :: 3.8", - "Topic :: Communications", - "Intended Audience :: Developers", - ], - packages=find_packages(exclude=[]), - include_package_data=True, - ) - - +setup( + name="knx-stack", + version="0.9.2", + description="A python3 KNX stack for USB HID and KNXnet IP", + url="https://github.com/majamassarini/knx-stack", + long_description=long_description, + long_description_content_type="text/markdown", + author="Maja Massarini", + author_email="maja.massarini@gmail.com", + license="MIT", + classifiers=[ + "Development Status :: 3 - Alpha", + "License :: OSI Approved :: MIT License", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python :: 3.8", + "Topic :: Communications", + "Intended Audience :: Developers", + ], + packages=find_packages(exclude=[]), + include_package_data=True, +) From 1d1ec8293b2415cf5447b36c3f5400070753cfb8 Mon Sep 17 00:00:00 2001 From: Maja Massarini Date: Fri, 26 Jan 2024 09:54:43 +0100 Subject: [PATCH 2/2] Smallest configuration for blogpost --- .packit.yaml | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/.packit.yaml b/.packit.yaml index a17c24f..4e7eb19 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -1,23 +1,7 @@ -# See the documentation for more information: -# https://packit.dev/docs/configuration/ packit_instances: ["stg"] -specfile_path: python-knx-stack.spec - -# add or remove files that should be synced -synced_files: - - python-knx-stack.spec - - .packit.yaml - -#release_suffix: "" - -# name in upstream package repository or registry (e.g. in PyPI) -upstream_package_name: knx-stack -# downstream (Fedora) RPM package name -downstream_package_name: knx-stack - upstream_project_url: https://github.com/majamassarini/knx-stack -issue_repository: https://github.com/majamassarini/knx-stack +specfile_path: python-knx-stack.spec jobs: - job: copr_build @@ -25,19 +9,14 @@ jobs: targets: fedora-stable owner: mmassari project: knx-stack - - job: copr_build - trigger: commit - targets: fedora-stable - owner: mmassari - project: knx-stack - job: vm_image_build trigger: pull_request - copr_chroot: fedora-36-x86_64 + copr_chroot: fedora-39-x86_64 owner: mmassari project: knx-stack image_customizations: packages: [python-knx-stack] - image_distribution: fedora-36 + image_distribution: fedora-39 image_request: architecture: x86_64 image_type: aws