Skip to content

Commit deadefc

Browse files
2.0.0 (#24)
1 parent 8767ce2 commit deadefc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1736
-939
lines changed

.flake8

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
[flake8]
2+
# spellcheck
3+
dictionaries = en_US,python,technical
4+
25
ignore =
36
# E201 whitespace after '('
47
E201,
@@ -13,6 +16,11 @@ ignore =
1316
# E303 too many blank lines
1417
E303,
1518

19+
20+
per-file-ignores =
21+
src/sml2mqtt/config/*:N805
22+
tests/*:E501
23+
1624
max-line-length = 120
1725
exclude =
1826
.git,
@@ -23,7 +31,3 @@ exclude =
2331
conf,
2432
__init__.py,
2533
tests/conftest.py,
26-
27-
# the interfaces will throw unused imports
28-
HABApp/openhab/interface.py,
29-
HABApp/openhab/interface_async.py,
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Publish sml2mqtt to dockerhub
2+
on:
3+
release:
4+
types: [published]
5+
# on: [push, pull_request]
6+
7+
8+
jobs:
9+
buildx:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
with:
14+
ref: master
15+
16+
- name: Set up QEMU
17+
uses: docker/setup-qemu-action@v2
18+
with:
19+
platforms: all
20+
21+
- name: Set up Docker Buildx
22+
id: buildx
23+
uses: docker/setup-buildx-action@v2
24+
with:
25+
version: latest
26+
27+
- name: Login to DockerHub
28+
uses: docker/login-action@v2
29+
with:
30+
username: ${{ secrets.DOCKER_HUB_USER }}
31+
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
32+
33+
- name: Build and push
34+
id: docker_build
35+
uses: docker/build-push-action@v4
36+
with:
37+
push: true
38+
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
39+
tags: |
40+
spacemanspiff2007/sml2mqtt:latest
41+
spacemanspiff2007/sml2mqtt:${{ github.ref_name }}
42+
43+
- name: Image digest
44+
run: echo ${{ steps.docker_build.outputs.digest }}

.github/workflows/run_tox.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,22 @@ name: Tests
33
on: [push, pull_request]
44

55
jobs:
6-
test:
6+
pre-commit:
7+
name:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- uses: actions/setup-python@v4
12+
with:
13+
python-version: '3.10'
14+
- uses: pre-commit/action@v3.0.0
15+
16+
17+
tests:
18+
needs: pre-commit
719
runs-on: ubuntu-latest
820
strategy:
9-
max-parallel: 2
21+
max-parallel: 4
1022
matrix:
1123
python-version: ['3.8', '3.9', '3.10', '3.11']
1224

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@
33
__pycache__
44
/build
55
/venv/
6+
7+
# sphinx
8+
build
9+
make.bat

.pre-commit-config.yaml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,52 @@ repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
33
rev: v4.4.0
44
hooks:
5+
- id: check-ast
6+
- id: check-builtin-literals
7+
- id: check-docstring-first
8+
- id: check-merge-conflict
9+
# - id: check-toml
510
- id: check-yaml
11+
- id: debug-statements
612
- id: end-of-file-fixer
713
- id: trailing-whitespace
814

15+
916
- repo: https://github.com/pycqa/isort
10-
rev: v5.11.3
17+
rev: 5.12.0
1118
hooks:
1219
- id: isort
1320
name: isort (python)
1421

22+
1523
- repo: https://github.com/PyCQA/flake8
1624
rev: '6.0.0'
1725
hooks:
1826
- id: flake8
27+
additional_dependencies:
28+
- flake8-bugbear==23.2.13
29+
- flake8-comprehensions==3.10.1
30+
- flake8-pytest-style==1.6
31+
# - flake8-spellcheck==0.28
32+
# - flake8-unused-arguments==0.0.12
33+
- flake8-noqa==1.3
34+
- pep8-naming==0.13.3
35+
36+
37+
- repo: https://github.com/asottile/pyupgrade
38+
rev: v3.3.1
39+
hooks:
40+
- id: pyupgrade
41+
args: ["--py38-plus"]
42+
43+
44+
- repo: https://github.com/pre-commit/pygrep-hooks
45+
rev: v1.10.0
46+
hooks:
47+
- id: rst-backticks
48+
49+
50+
- repo: meta
51+
hooks:
52+
- id: check-hooks-apply
53+
- id: check-useless-excludes

.readthedocs.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# .readthedocs.yml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
# Build documentation in the docs/ directory with Sphinx
9+
sphinx:
10+
configuration: docs/conf.py
11+
12+
# Build documentation with MkDocs
13+
#mkdocs:
14+
# configuration: mkdocs.yml
15+
16+
# Optionally build your docs in additional formats such as PDF and ePub
17+
formats: all
18+
19+
build:
20+
os: ubuntu-22.04
21+
tools:
22+
python: "3.10"
23+
24+
# Optionally set the version of Python and requirements required to build your docs
25+
python:
26+
install:
27+
- requirements: requirements_setup.txt
28+
- requirements: docs/requirements.txt
29+
- method: pip
30+
path: .

Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM python:3.10-alpine
2+
3+
VOLUME /sml2mqtt
4+
5+
COPY . /tmp/sml2mqtt_src
6+
7+
RUN apk add --no-cache python3 py3-wheel py3-pip gcc musl-dev python3-dev && \
8+
# install sml2mqtt from local dir
9+
pip install --no-cache-dir /tmp/sml2mqtt_src && \
10+
# cleanup
11+
pip install --no-cache-dir pyclean && pyclean /usr && pip uninstall -y pyclean setuptools wheel pip && \
12+
apk del py3-wheel py3-pip gcc musl-dev python3-dev && \
13+
rm -fr /tmp/*
14+
15+
WORKDIR /sml2mqtt
16+
CMD [ "sml2mqtt", "--config", "/sml2mqtt/config.yml"]

docs/_static/theme_changes.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
/* On screens that are 767px or more */
3+
@media screen and (min-width: 767px) {
4+
.wy-nav-content {
5+
max-width: 1100px !important;
6+
}
7+
}

docs/conf.py

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import os
2+
import re
3+
import sys
4+
5+
RTD_BUILD = os.environ.get('READTHEDOCS') == 'True'
6+
7+
8+
# Configuration file for the Sphinx documentation builder.
9+
#
10+
# For the full list of built-in configuration values, see the documentation:
11+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
12+
13+
# -- Project information -----------------------------------------------------
14+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
15+
16+
project = 'sml2mqtt'
17+
copyright = '2023, spacemanspiff2007'
18+
author = 'spacemanspiff2007'
19+
20+
# -- General configuration ---------------------------------------------------
21+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
22+
23+
extensions = [
24+
'sphinx_exec_code',
25+
'sphinx.ext.autodoc',
26+
'sphinx.ext.intersphinx',
27+
'sphinx_autodoc_typehints',
28+
'sphinxcontrib.autodoc_pydantic',
29+
]
30+
31+
templates_path = ['_templates']
32+
exclude_patterns = []
33+
34+
35+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-add_module_names
36+
# use class name instead of FQN
37+
add_module_names = False
38+
39+
40+
# -- Options for HTML output -------------------------------------------------
41+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
42+
43+
html_theme = 'sphinx_rtd_theme'
44+
html_static_path = ['_static']
45+
html_css_files = ['theme_changes.css']
46+
47+
48+
# -- Options for autodoc -------------------------------------------------
49+
autodoc_member_order = 'bysource'
50+
autoclass_content = 'class'
51+
52+
# so autodoc does find the source
53+
sys.path.insert(0, os.path.join(os.path.abspath('..'), 'src'))
54+
55+
56+
# -- Options for autodoc pydantic -------------------------------------------------
57+
# https://autodoc-pydantic.readthedocs.io/en/stable/
58+
59+
# No config on member
60+
autodoc_pydantic_model_show_config_member = False
61+
autodoc_pydantic_model_show_config_summary = False
62+
63+
# No validators
64+
autodoc_pydantic_model_show_validator_summary = False
65+
autodoc_pydantic_model_show_validator_members = False
66+
67+
# Model configuration
68+
autodoc_pydantic_model_signature_prefix = 'settings'
69+
autodoc_pydantic_model_show_json = False
70+
autodoc_pydantic_model_show_field_summary = False
71+
autodoc_pydantic_model_member_order = 'bysource'
72+
73+
# Field config
74+
autodoc_pydantic_field_show_alias = False
75+
autodoc_pydantic_field_list_validators = False
76+
autodoc_pydantic_field_swap_name_and_alias = True
77+
78+
# -- Options for intersphinx -------------------------------------------------
79+
# https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html
80+
if RTD_BUILD:
81+
intersphinx_mapping = {
82+
'python': ('https://docs.python.org/3', None)
83+
}
84+
85+
# -- Options for nitpick -------------------------------------------------
86+
# Don't show warnings for missing python references since these are created via intersphinx during the RTD build
87+
if not RTD_BUILD:
88+
nitpick_ignore_regex = [
89+
(re.compile(r'^py:class'), re.compile(r'pathlib\..+')),
90+
(re.compile(r'^py:data'), re.compile(r'typing\..+')),
91+
(re.compile(r'^py:class'), re.compile(r'pydantic\..+|.+Constrained(?:Str|Int)Value')),
92+
]

0 commit comments

Comments
 (0)