diff --git a/.devcontainer.json b/.devcontainer.json index 5cec644..3e32baf 100644 --- a/.devcontainer.json +++ b/.devcontainer.json @@ -1,6 +1,6 @@ { "name": "ludeeus/integration_blueprint", - "image": "mcr.microsoft.com/devcontainers/python:1-3.12", + "image": "mcr.microsoft.com/devcontainers/python:3.12", "postCreateCommand": "scripts/setup", "forwardPorts": [ 8123 @@ -14,33 +14,28 @@ "customizations": { "vscode": { "extensions": [ - "ms-python.python", + "charliermarsh.ruff", "github.vscode-pull-request-github", - "ryanluker.vscode-coverage-gutters", + "ms-python.python", "ms-python.vscode-pylance", - "ms-python.black-formatter", - "ms-python.pylint" + "ryanluker.vscode-coverage-gutters" ], "settings": { "files.eol": "\n", "editor.tabSize": 4, - "python.pythonPath": "/usr/bin/python3", - "python.analysis.autoSearchPaths": false, - "[python]": { - "editor.defaultFormatter": "ms-python.black-formatter" - }, - "black-formatter.path": [ - "/usr/local/py-utils/bin/black" - ], - "editor.formatOnPaste": false, + "editor.formatOnPaste": true, "editor.formatOnSave": true, - "editor.formatOnType": true, - "files.trimTrailingWhitespace": true + "editor.formatOnType": false, + "files.trimTrailingWhitespace": true, + "python.analysis.typeCheckingMode": "basic", + "python.analysis.autoImportCompletions": true, + "python.defaultInterpreterPath": "/usr/local/bin/python", + "[python]": { + "editor.defaultFormatter": "charliermarsh.ruff" + } } } }, "remoteUser": "vscode", - "features": { - "ghcr.io/devcontainers/features/rust:1": {} - } + "features": {} } diff --git a/.devcontainer/container/makefiles/integration.mk b/.devcontainer/container/makefiles/integration.mk index 3de0d34..2c66929 100644 --- a/.devcontainer/container/makefiles/integration.mk +++ b/.devcontainer/container/makefiles/integration.mk @@ -10,11 +10,11 @@ up: set-version: ## Set Home Assistant version @bash /opt/container/helpers/homeassistant/set-version.sh -install: ## Install Home Assistant dev in the container +upgrade: ## Upgrade Home Assistant to latest dev in the container @python3 -m pip --disable-pip-version-check install --upgrade git+https://github.com/home-assistant/home-assistant.git@dev -upgrade: ## Upgrade Home Assistant to latest dev in the container - install +install: ## Install Home Assistant dev in the container + upgrade check-config: ## Check Home Assistant config @hass -c /config --script check_config diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4e07fbc..d337961 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,7 +14,7 @@ jobs: runs-on: "ubuntu-latest" steps: - name: "Checkout the repository" - uses: "actions/checkout@v4.1.0" + uses: "actions/checkout@v4.1.7" - name: "Set up Python" uses: actions/setup-python@v5 @@ -25,5 +25,8 @@ jobs: - name: "Install requirements" run: python3 -m pip install -r requirements.txt - - name: "Run" + - name: "Lint" run: python3 -m ruff check . + + - name: "Format" + run: python3 -m ruff format . --check diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 3f643d1..124bc91 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -17,7 +17,7 @@ jobs: runs-on: "ubuntu-latest" steps: - name: "Checkout the repository" - uses: "actions/checkout@v4.1.0" + uses: "actions/checkout@v4.1.7" - name: "Run hassfest validation" uses: "home-assistant/actions/hassfest@master" @@ -27,7 +27,7 @@ jobs: runs-on: "ubuntu-latest" steps: - name: "Checkout the repository" - uses: "actions/checkout@v4.1.0" + uses: "actions/checkout@v4.1.7" - name: "Run HACS validation" uses: "hacs/action@main" diff --git a/.gitignore b/.gitignore index 85f2aa9..b679a3d 100644 --- a/.gitignore +++ b/.gitignore @@ -60,6 +60,7 @@ ENV/ env.bak/ venv.bak/ coverage.xml +.ruff_cache # mkdocs documentation /site diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d602d3f..f1c52ee 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -45,10 +45,6 @@ repos: - --format=custom - --configfile=tests/bandit.yaml files: ^(custom_components|bin|tests)/.+\.py$ - - repo: https://github.com/pre-commit/mirrors-isort - rev: v5.10.1 - hooks: - - id: isort - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 hooks: diff --git a/.ruff.toml b/.ruff.toml index eb68b8c..238e0df 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -2,40 +2,17 @@ target-version = "py312" -lint.select = [ - "B007", # Loop control variable {name} not used within loop body - "B014", # Exception handler with duplicate exception - "C", # complexity - "D", # docstrings - "E", # pycodestyle - "F", # pyflakes/autoflake - "ICN001", # import concentions; {name} should be imported as {asname} - "PGH004", # Use specific rule codes when using noqa - "PLC0414", # Useless import alias. Import alias does not rename original package. - "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} - "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 - "T20", # flake8-print - "TRY004", # Prefer TypeError exception for invalid type - "RUF006", # Store a reference to the return value of asyncio.create_task - "UP", # pyupgrade - "W", # pycodestyle +[lint] +select = [ + "ALL", ] - -lint.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 - "D404", # First word of the docstring should not be This - "D406", # Section name should end with a newline - "D407", # Section name underlining - "D411", # Missing blank line before section - "E501", # line too long - "E731", # do not assign a lambda expression, use a def +ignore = [ + "ANN101", # Missing type annotation for `self` in method + "ANN401", # Dynamically typed expressions (typing.Any) are disallowed + "D203", # no-blank-line-before-class (incompatible with formatter) + "D212", # multi-line-summary-first-line (incompatible with formatter) + "COM812", # incompatible with formatter + "ISC001", # incompatible with formatter ] [lint.flake8-pytest-style] @@ -46,3 +23,6 @@ keep-runtime-typing = true [lint.mccabe] max-complexity = 25 + +[lint.per-file-ignores] +"tests/*.py" = ["ANN001", "ANN201", "S101", "SLF001"] diff --git a/config/configuration.yaml b/config/configuration.yaml index 004a7ea..a030790 100644 --- a/config/configuration.yaml +++ b/config/configuration.yaml @@ -1,12 +1,19 @@ +# https://www.home-assistant.io/integrations/default_config/ default_config: +# https://www.home-assistant.io/integrations/homeassistant/ +homeassistant: + debug: true + +# https://www.home-assistant.io/integrations/logger/ logger: default: error logs: custom_components.gismeteo: debug -# If you need to debug uncomment the line below (doc: https://www.home-assistant.io/integrations/debugpy/) -# debugpy: +# https://www.home-assistant.io/integrations/debugpy/ +# If you need to debug uncomment the line below +#debugpy: gismeteo: sweet_home: diff --git a/custom_components/gismeteo/const.py b/custom_components/gismeteo/const.py index 12ed6a8..b2373f4 100644 --- a/custom_components/gismeteo/const.py +++ b/custom_components/gismeteo/const.py @@ -41,7 +41,7 @@ # Base component constants NAME: Final = "Gismeteo" DOMAIN: Final = "gismeteo" -VERSION: Final = "3.0.1" +VERSION: Final = "3.0.2-alpha" ATTRIBUTION: Final = "Data provided by Gismeteo" ISSUE_URL: Final = "https://github.com/Limych/ha-gismeteo/issues" # diff --git a/custom_components/gismeteo/manifest.json b/custom_components/gismeteo/manifest.json index e623560..07f37e7 100644 --- a/custom_components/gismeteo/manifest.json +++ b/custom_components/gismeteo/manifest.json @@ -14,5 +14,5 @@ "requirements": [ "beautifulsoup4~=4.12" ], - "version": "3.0.1" + "version": "3.0.2-alpha" } \ No newline at end of file diff --git a/hacs.json b/hacs.json index e78968a..e7ba83e 100644 --- a/hacs.json +++ b/hacs.json @@ -1,8 +1,6 @@ { "name": "Gismeteo", - "filename": "gismeteo.zip", "hide_default_branch": true, - "homeassistant": "2024.4.0", - "render_readme": true, - "zip_release": true + "homeassistant": "2024.6.0", + "render_readme": true } diff --git a/requirements-dev.txt b/requirements-dev.txt index 3357394..1ab88bd 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,7 +1,7 @@ -r requirements-test.txt -black~=24.4 -packaging~=24.0 -pre-commit~=3.7 -PyGithub~=2.3 -pyupgrade~=3.15 +black~=24.8 +packaging~=24.1 +pre-commit~=3.8 +PyGithub~=2.4 +pyupgrade~=3.17 yamllint~=1.35 diff --git a/requirements-test.txt b/requirements-test.txt index ac9f830..5effd1d 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -2,9 +2,9 @@ async-timeout asynctest~=0.13 colorlog~=6.8 -flake8~=7.0 +flake8~=7.1 flake8-docstrings~=1.7 -mypy~=1.10 +mypy~=1.11 pylint~=3.2 pylint-strict-informational==0.1 pytest>=7.2 diff --git a/requirements.txt b/requirements.txt index d709277..4232f4c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -homeassistant>=2024.4.0 -pip>=24.0 +homeassistant>=2024.6.0 +pip>=21.3.1 beautifulsoup4~=4.12 diff --git a/scripts/lint b/scripts/lint index 9b5b1df..5d68d15 100755 --- a/scripts/lint +++ b/scripts/lint @@ -4,4 +4,5 @@ set -e cd "$(dirname "$0")/.." +ruff format . ruff check . --fix