Skip to content

Commit

Permalink
Lint project
Browse files Browse the repository at this point in the history
  • Loading branch information
tetienne committed Jun 1, 2022
1 parent 62c78cf commit 0cf5a5d
Show file tree
Hide file tree
Showing 14 changed files with 255 additions and 125 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/hassfest.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Validate with hassfest

on:
push:
pull_request:
schedule:
- cron: "0 0 * * *"
Expand All @@ -10,5 +9,5 @@ jobs:
validate:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v2"
- uses: actions/checkout@v2
- uses: home-assistant/actions/hassfest@master
12 changes: 12 additions & 0 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Linters

on:
pull_request:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/[email protected]
52 changes: 0 additions & 52 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,17 @@
# This is a basic workflow to help you get started with Actions

name: Release

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [main]
# pull_request:
# branches: [main]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# # Runs a single command using the runners shell
# - name: Run a one-line script
# run: echo Hello, world!

- name: Read Properties
id: read_property
uses: ashley-taylor/[email protected]
Expand All @@ -41,12 +24,7 @@ jobs:
uses: joutvhu/get-release@v1
with:
latest: true
# Tag name start with `v`
# attern: '^v.*'
# Including pre-release
prerelease: true
# Fail when no release was found
# throwing: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -64,47 +42,17 @@ jobs:
if: ${{ steps.read_property.outputs.value != steps.get_latest_release.outputs.name }}
uses: TheDoctor0/[email protected]
with:
# Filename for archive
filename: toshiba_ac-${{ steps.read_property.outputs.value }}.zip
# Base path for archive files
# path: # optional, default is .
# Working directory before zipping
directory: custom_components/
# List of excluded files / directories
# exclusions:
# Tool to use for archiving
type: zip

- name: Create release
if: ${{ steps.read_property.outputs.value != steps.get_latest_release.outputs.name }}
uses: meeDamian/[email protected]
with:
# Github API token to be used. Quite unavoidable, I'm afraid.
token: ${{ secrets.GITHUB_TOKEN }}
# A tag for the release. Required UNLESS action is run on tag push (meaning: '$GITHUB_REF' contains 'ref/tag/<TAG>').
tag: ${{ steps.read_property.outputs.value }}
# Unnecessary, if the tag provided is a git tag. If it isn't, release will be created off 'master'.
# commitish: # optional
# Name the release, the more creative, the better.
name: ${{ steps.read_property.outputs.value }}
# Longer description of the release, ex. changelog, or info about contributors.
body: ${{ github.event.head_commit.message }}
# Keep the Release as draft and don't publish it. With no 'files', the default is 'false'. With 'files' default is to 'un-draft' the release only after and if all assets upload successfully. Keep it private with explicit 'false'.
# draft: # optional
# Marks Release as a pre-Release.
# prerelease: # optional
# A whitespace-separated(!) list of files to be uploaded. It's impossible to pass a list here, so make sure filenames don't contain spaces nor colons in their names/paths. Optionally custom asset name can be specified by pre-pending it to the name, ex: 'asset-name.tgz:./folder-to-be-uploaded/'.
files: custom_components/toshiba_ac-${{ steps.read_property.outputs.value }}.zip
# Default is 'true', which compresses both files, and folders. 'false' compresses nothing, but will error out on folders, as they can't be uploaded. 'folders' applies compression to folders only.
gzip: false
# Set to 'true' to allow for release overriding.
# allow_override: # optional
# - name: Upload Release Asset
# uses: actions/upload-release-asset@v1
# with:
# upload_url: ${{ steps.get_current_release.outputs.upload_url }}
# asset_path: ./my-artifact.zip
# asset_name: my-artifact.zip
# asset_content_type: application/zip
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: HACS Validate

on:
push:
pull_request:
schedule:
- cron: "0 0 * * *"
Expand All @@ -15,3 +14,4 @@ jobs:
uses: "hacs/action@main"
with:
category: "integration"
comment: false
39 changes: 39 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v2.31.1
hooks:
- id: pyupgrade
args: [--py37-plus]
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
args:
- --safe
- --quiet
files: ^((custom_components)/.+)?[^/]+\.py$
- repo: https://github.com/codespell-project/codespell
rev: v2.1.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,*.md"
- --quiet-level=2
exclude_types: [csv, json]
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
additional_dependencies:
- flake8-docstrings==1.5.0
- pydocstyle==5.1.1
files: ^(custom_components)/.+\.py$
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.26.3
hooks:
- id: yamllint
61 changes: 61 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
ignore: |
.github
rules:
braces:
level: error
min-spaces-inside: 0
max-spaces-inside: 1
min-spaces-inside-empty: -1
max-spaces-inside-empty: -1
brackets:
level: error
min-spaces-inside: 0
max-spaces-inside: 0
min-spaces-inside-empty: -1
max-spaces-inside-empty: -1
colons:
level: error
max-spaces-before: 0
max-spaces-after: 1
commas:
level: error
max-spaces-before: 0
min-spaces-after: 1
max-spaces-after: 1
comments:
level: error
require-starting-space: true
min-spaces-from-content: 2
comments-indentation:
level: error
document-end:
level: error
present: false
document-start:
level: error
present: false
empty-lines:
level: error
max: 1
max-start: 0
max-end: 1
hyphens:
level: error
max-spaces-after: 1
indentation:
level: error
spaces: 2
indent-sequences: true
check-multi-line-strings: false
key-duplicates:
level: error
line-length: disable
new-line-at-end-of-file:
level: error
new-lines:
level: error
type: unix
trailing-spaces:
level: error
truthy:
level: warning
10 changes: 7 additions & 3 deletions custom_components/toshiba_ac/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""The Toshiba AC integration."""
from __future__ import annotations

from toshiba_ac.device_manager import ToshibaAcDeviceManager

from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant

from .const import DOMAIN

from toshiba_ac.device_manager import ToshibaAcDeviceManager

PLATFORMS = ["climate", "sensor"]


Expand All @@ -24,7 +24,11 @@ async def async_setup(hass: HomeAssistant, config: dict):
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Toshiba AC from a config entry."""
device_manager = ToshibaAcDeviceManager(
hass.loop, entry.data["username"], entry.data["password"], entry.data["device_id"], entry.data["sas_token"]
hass.loop,
entry.data["username"],
entry.data["password"],
entry.data["device_id"],
entry.data["sas_token"],
)

try:
Expand Down
Loading

0 comments on commit 0cf5a5d

Please sign in to comment.