Skip to content

Commit

Permalink
Merge pull request #11 from astrandb/NewDevContainer
Browse files Browse the repository at this point in the history
New dev container
  • Loading branch information
astrandb authored Jul 19, 2023
2 parents bbe683e + fa635b6 commit 5248f8c
Show file tree
Hide file tree
Showing 20 changed files with 304 additions and 126 deletions.
55 changes: 55 additions & 0 deletions .devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"name": "astrandb/dev-viva",
"image": "mcr.microsoft.com/vscode/devcontainers/python:0-3.11-bullseye",
"postCreateCommand": "scripts/setup",
"appPort": ["9124:8123"],
"portsAttributes": {
"8123": {
"label": "Home Assistant internal",
"onAutoForward": "notify"
},
"9124": {
"label": "Home Assistant remote",
"onAutoForward": "notify"
}
},
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"github.vscode-pull-request-github",
"ryanluker.vscode-coverage-gutters",
"ms-python.vscode-pylance",
"ms-python.pylint",
"ms-python.black-formatter",
"thibault-vanderseypen.i18n-json-editor"
],
"settings": {
"files.eol": "\n",
"editor.tabSize": 4,
"python.pythonPath": "/usr/bin/python3",
"python.analysis.autoSearchPaths": false,
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true
},
"python.formatting.provider": "none",
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true,
"[markdown]": {
"files.trimTrailingWhitespace": false
},
"i18nJsonEditor.forceKeyUPPERCASE": false,
"i18nJsonEditor.supportedFolders": ["translations", "i18n"]
}
}
},
"remoteUser": "vscode",
"features": {
"ghcr.io/devcontainers/features/rust:1": {}
}
}
9 changes: 0 additions & 9 deletions .devcontainer/configuration.yaml

This file was deleted.

48 changes: 0 additions & 48 deletions .devcontainer/devcontainer.json

This file was deleted.

15 changes: 15 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
version: 2
updates:
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: 'weekly'

- package-ecosystem: 'pip'
directory: '/'
schedule:
interval: 'weekly'
ignore:
# Dependabot should not update Home Assistant as that should match the homeassistant key in hacs.json
- dependency-name: 'homeassistant'
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Home Assistant confis
config/*
!config/configuration.yaml

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
62 changes: 33 additions & 29 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-json
exclude: (.vscode|.devcontainer)
- id: pretty-format-json
args: ["--autofix", "--no-ensure-ascii", "--top-keys=domain,name"]
files: manifest.json
- id: pretty-format-json
args: ["--autofix", "--no-ensure-ascii", "--top-keys=name"]
files: hacs.json
- id: pretty-format-json
args: ["--autofix", "--no-ensure-ascii", "--no-sort-keys"]
files: (/strings\.json$|translations/.+\.json$)
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black
args:
- --quiet
files: ^((custom_components|homeassistant|pylint|script|tests)/.+)?[^/]+\.py$
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.278
hooks:
- id: ruff
args:
- --fix
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black
args:
- --quiet
files: ^((custom_components|homeassistant|pylint|script|tests)/.+)?[^/]+\.py$
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-json
exclude: (.vscode|.devcontainer)
- id: pretty-format-json
args: ['--autofix', '--no-ensure-ascii', '--top-keys=domain,name']
files: manifest.json
- id: pretty-format-json
args: ['--autofix', '--no-ensure-ascii', '--top-keys=name']
files: hacs.json
- id: pretty-format-json
args: ['--autofix', '--no-ensure-ascii', '--no-sort-keys']
files: (/strings\.json$|translations/.+\.json$)
- id: check-yaml
args: ['--unsafe']
- id: check-added-large-files
- id: check-shebang-scripts-are-executable
100 changes: 100 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# The contents of this file is based on https://github.com/home-assistant/core/blob/dev/pyproject.toml

target-version = "py310"

select = [
"B002", # Python does not support the unary prefix increment
"B007", # Loop control variable {name} not used within loop body
"B014", # Exception handler with duplicate exception
"B023", # Function definition does not bind loop variable {name}
"B026", # Star-arg unpacking after a keyword argument is strongly discouraged
"C", # complexity
"COM818", # Trailing comma on bare tuple prohibited
"D", # docstrings
"E", # pycodestyle
"F", # pyflakes/autoflake
"G", # flake8-logging-format
"I", # isort
"ICN001", # import concentions; {name} should be imported as {asname}
"ISC001", # Implicitly concatenated string literals on one line
"N804", # First argument of a class method should be named cls
"N805", # First argument of a method should be named self
"N815", # Variable {name} in class scope should not be mixedCase
"PGH001", # No builtin eval() allowed
"PGH004", # Use specific rule codes when using noqa
"PLC0414", # Useless import alias. Import alias does not rename original package.
"PLC", # pylint
"PLE", # pylint
"PLR", # pylint
"PLW", # pylint
"Q000", # Double quotes found but single quotes preferred
"RUF006", # Store a reference to the return value of asyncio.create_task
"S102", # Use of exec detected
"S103", # bad-file-permissions
"S108", # hardcoded-temp-file
"S306", # suspicious-mktemp-usage
"S307", # suspicious-eval-usage
"S313", # suspicious-xmlc-element-tree-usage
"S314", # suspicious-xml-element-tree-usage
"S315", # suspicious-xml-expat-reader-usage
"S316", # suspicious-xml-expat-builder-usage
"S317", # suspicious-xml-sax-usage
"S318", # suspicious-xml-mini-dom-usage
"S319", # suspicious-xml-pull-dom-usage
"S320", # suspicious-xmle-tree-usage
"S601", # paramiko-call
"S602", # subprocess-popen-with-shell-equals-true
"S604", # call-with-shell-equals-true
"S608", # hardcoded-sql-expression
"S609", # unix-command-wildcard-injection
"SIM105", # Use contextlib.suppress({exception}) instead of try-except-pass
"SIM117", # Merge with-statements that use the same scope
"SIM118", # Use {key} in {dict} instead of {key} in {dict}.keys()
"SIM201", # Use {left} != {right} instead of not {left} == {right}
"SIM208", # Use {expr} instead of not (not {expr})
"SIM212", # Use {a} if {a} else {b} instead of {b} if not {a} else {a}
"SIM300", # Yoda conditions. Use 'age == 42' instead of '42 == age'.
"SIM401", # Use get from dict with default instead of an if block
"T100", # Trace found: {name} used
"T20", # flake8-print
"TRY004", # Prefer TypeError exception for invalid type
"TRY200", # Use raise from to specify exception cause
"TRY302", # Remove exception handler; error is immediately re-raised
"UP", # pyupgrade
"W", # pycodestyle
]

ignore = [
"D202", # No blank lines allowed after function docstring
"D203", # 1 blank line required before class docstring
"D213", # Multi-line docstring summary should start at the second line
"D406", # Section name should end with a newline
"D407", # Section name underlining
"E501", # line too long
"E731", # do not assign a lambda expression, use a def
"PLC1901", # Lots of false positives
# False positives https://github.com/astral-sh/ruff/issues/5386
"PLC0208", # Use a sequence type instead of a `set` when iterating over values
"PLR0911", # Too many return statements ({returns} > {max_returns})
"PLR0912", # Too many branches ({branches} > {max_branches})
"PLR0913", # Too many arguments to function call ({c_args} > {max_args})
"PLR0915", # Too many statements ({statements} > {max_statements})
"PLR2004", # Magic value used in comparison, consider replacing {value} with a constant variable
"PLW2901", # Outer {outer_kind} variable {name} overwritten by inner {inner_kind} target
"UP006", # keep type annotation style as is
"UP007", # keep type annotation style as is
# Ignored due to performance: https://github.com/charliermarsh/ruff/issues/2923
"UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)`

]

[isort]
force-sort-within-sections = true
known-first-party = ["homeassistant"]
combine-as-imports = true

[flake8-pytest-style]
fixture-parentheses = false

[mccabe]
max-complexity = 25
8 changes: 0 additions & 8 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +0,0 @@
{
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.pythonPath": "/usr/local/bin/python",
"files.associations": {
"*.yaml": "home-assistant"
}
}
18 changes: 6 additions & 12 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,20 @@
{
"label": "Run Home Assistant on port 9124",
"type": "shell",
"command": "container start",
"command": "scripts/develop",
"problemMatcher": []
},
{
"label": "Run Home Assistant configuration against /config",
"label": "Upgrade Home Assistant to latest (beta)",
"type": "shell",
"command": "container check",
"command": "scripts/upgrade",
"problemMatcher": []
},
{
"label": "Upgrade Home Assistant to latest dev",
"label": "Lint with ruff",
"type": "shell",
"command": "container install",
"problemMatcher": []
},
{
"label": "Install a specific version of Home Assistant",
"type": "shell",
"command": "container set-version",
"command": "scripts/lint",
"problemMatcher": []
}
]
}
}
22 changes: 11 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ bump_minor:
bump_major:
bump2version --allow-dirty major $(src_dir)/const.py $(src_dir)/manifest.json

lint:
isort $(src_dir)
black $(src_dir)
flake8 $(src_dir)
# lint:
# isort $(src_dir)
# black $(src_dir)
# flake8 $(src_dir)

.venv:
python3.9 -m venv .venv
# .venv:
# python3.9 -m venv .venv

install_dev: | .venv
(. .venv/bin/activate; \
pip install -Ur requirements-dev.txt )
# install_dev: | .venv
# (. .venv/bin/activate; \
# pip install -Ur requirements-dev.txt )

clean:
rm -rf .venv $(src_dir)/__pycache__
# clean:
# rm -rf .venv $(src_dir)/__pycache__
16 changes: 16 additions & 0 deletions config/configuration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

logger:
default: info
logs:
homeassistant.components.viva: debug
2 changes: 0 additions & 2 deletions requirements-dev.txt

This file was deleted.

Loading

0 comments on commit 5248f8c

Please sign in to comment.