From e1ee7b16ee588b22ffa6592c539abdf4563ab144 Mon Sep 17 00:00:00 2001 From: Evan Fiordeliso Date: Sun, 29 Jan 2023 09:34:51 -0500 Subject: [PATCH] Initial commit --- .pre-commit-config.yaml | 58 ++++++++++++++++++ README.md | 3 + custom_components/__init__.py | 0 custom_components/flickerstrip/__init__.py | 7 +++ custom_components/flickerstrip/const.py | 1 + custom_components/flickerstrip/manifest.json | 11 ++++ hacs.json | 5 ++ requirements.test.txt | 3 + setup.cfg | 62 ++++++++++++++++++++ tests/__init__.py | 0 tests/bandit.yaml | 17 ++++++ tests/test_init.py | 9 +++ 12 files changed, 176 insertions(+) create mode 100644 .pre-commit-config.yaml create mode 100644 README.md create mode 100644 custom_components/__init__.py create mode 100644 custom_components/flickerstrip/__init__.py create mode 100644 custom_components/flickerstrip/const.py create mode 100644 custom_components/flickerstrip/manifest.json create mode 100644 hacs.json create mode 100644 requirements.test.txt create mode 100644 setup.cfg create mode 100644 tests/__init__.py create mode 100644 tests/bandit.yaml create mode 100644 tests/test_init.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..9931e3a --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,58 @@ +repos: + - repo: https://github.com/asottile/pyupgrade + rev: v2.3.0 + hooks: + - id: pyupgrade + args: [--py37-plus] + - repo: https://github.com/psf/black + rev: 19.10b0 + hooks: + - id: black + args: + - --safe + - --quiet + files: ^((homeassistant|script|tests)/.+)?[^/]+\.py$ + - repo: https://github.com/codespell-project/codespell + rev: v1.16.0 + hooks: + - id: codespell + args: + - --ignore-words-list=hass,alot,datas,dof,dur,farenheit,hist,iff,ines,ist,lightsensor,mut,nd,pres,referer,ser,serie,te,technik,ue,uint,visability,wan,wanna,withing + - --skip="./.*,*.csv,*.json" + - --quiet-level=2 + exclude_types: [csv, json] + - repo: https://gitlab.com/pycqa/flake8 + rev: 3.8.1 + hooks: + - id: flake8 + additional_dependencies: + - flake8-docstrings==1.5.0 + - pydocstyle==5.0.2 + files: ^(homeassistant|script|tests)/.+\.py$ + - repo: https://github.com/PyCQA/bandit + rev: 1.6.2 + hooks: + - id: bandit + args: + - --quiet + - --format=custom + - --configfile=tests/bandit.yaml + files: ^(homeassistant|script|tests)/.+\.py$ + - repo: https://github.com/pre-commit/mirrors-isort + rev: v4.3.21 + hooks: + - id: isort + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.4.0 + hooks: + - id: check-executables-have-shebangs + stages: [manual] + - id: check-json + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.770 + hooks: + - id: mypy + args: + - --pretty + - --show-error-codes + - --show-error-context diff --git a/README.md b/README.md new file mode 100644 index 0000000..49cca17 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Flickerstrip for Home Assistant + +## Installation diff --git a/custom_components/__init__.py b/custom_components/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/custom_components/flickerstrip/__init__.py b/custom_components/flickerstrip/__init__.py new file mode 100644 index 0000000..dfc62ba --- /dev/null +++ b/custom_components/flickerstrip/__init__.py @@ -0,0 +1,7 @@ +from homeassistant import core + + +async def async_setup(hass: core.HomeAssistant, config: dict) -> bool: + """Set up the Flickerstrip component.""" + # @TODO: Add setup code. + return True diff --git a/custom_components/flickerstrip/const.py b/custom_components/flickerstrip/const.py new file mode 100644 index 0000000..62517c7 --- /dev/null +++ b/custom_components/flickerstrip/const.py @@ -0,0 +1 @@ +DOMAIN = "flickerstrip" diff --git a/custom_components/flickerstrip/manifest.json b/custom_components/flickerstrip/manifest.json new file mode 100644 index 0000000..ac9d41f --- /dev/null +++ b/custom_components/flickerstrip/manifest.json @@ -0,0 +1,11 @@ +{ + "codeowners": ["@fifitido"], + "config_flow": true, + "dependencies": [], + "documentation": "https://git.fifitido.net/lib/hass_flickerstrip", + "domain": "flickerstrip", + "iot_class": "local_polling", + "name": "Flickerstrip", + "requirements": [], + "version": "1.0.0" +} diff --git a/hacs.json b/hacs.json new file mode 100644 index 0000000..5a972f2 --- /dev/null +++ b/hacs.json @@ -0,0 +1,5 @@ +{ + "name": "Flickerstrip", + "render_readme": true, + "iot_class": "local_polling" +} diff --git a/requirements.test.txt b/requirements.test.txt new file mode 100644 index 0000000..efeebaa --- /dev/null +++ b/requirements.test.txt @@ -0,0 +1,3 @@ +pytest +pytest-cov==2.9.0 +pytest-homeassistant-custom-component diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..6197927 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,62 @@ +[coverage:run] +source = + custom_components + +[coverage:report] +exclude_lines = + pragma: no cover + raise NotImplemented() + if __name__ == '__main__': + main() +show_missing = true + +[tool:pytest] +testpaths = tests +norecursedirs = .git +addopts = + --strict + --cov=custom_components + +[flake8] +# https://github.com/ambv/black#line-length +max-line-length = 88 +# E501: line too long +# W503: Line break occurred before a binary operator +# E203: Whitespace before ':' +# D202 No blank lines allowed after function docstring +# W504 line break after binary operator +ignore = + E501, + W503, + E203, + D202, + W504 + +[isort] +# https://github.com/timothycrosley/isort +# https://github.com/timothycrosley/isort/wiki/isort-Settings +# splits long import on multiple lines indented by 4 spaces +multi_line_output = 3 +include_trailing_comma=True +force_grid_wrap=0 +use_parentheses=True +line_length=88 +indent = " " +# by default isort don't check module indexes +not_skip = __init__.py +# will group `import x` and `from x import` of the same module. +force_sort_within_sections = true +sections = FUTURE,STDLIB,INBETWEENS,THIRDPARTY,FIRSTPARTY,LOCALFOLDER +default_section = THIRDPARTY +known_first_party = custom_components,tests +forced_separate = tests +combine_as_imports = true + +[mypy] +python_version = 3.7 +ignore_errors = true +follow_imports = silent +ignore_missing_imports = true +warn_incomplete_stub = true +warn_redundant_casts = true +warn_unused_configs = true diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/bandit.yaml b/tests/bandit.yaml new file mode 100644 index 0000000..ebd284e --- /dev/null +++ b/tests/bandit.yaml @@ -0,0 +1,17 @@ +# https://bandit.readthedocs.io/en/latest/config.html + +tests: + - B108 + - B306 + - B307 + - B313 + - B314 + - B315 + - B316 + - B317 + - B318 + - B319 + - B320 + - B325 + - B602 + - B604 diff --git a/tests/test_init.py b/tests/test_init.py new file mode 100644 index 0000000..fa13b14 --- /dev/null +++ b/tests/test_init.py @@ -0,0 +1,9 @@ +"""Test component setup.""" +from homeassistant.setup import async_setup_component + +from custom_components.flickerstrip.const import DOMAIN + + +async def test_async_setup(hass): + """Test the component gets setup.""" + assert await async_setup_component(hass, DOMAIN, {}) is True