Skip to content

Commit

Permalink
style(pre-commit): change pre-commit hooks to be remote and not local
Browse files Browse the repository at this point in the history
  • Loading branch information
xaviml committed Apr 16, 2022
1 parent 216d1b1 commit 6cb4810
Show file tree
Hide file tree
Showing 80 changed files with 121 additions and 162 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ jobs:
with:
languages: python
setup-python-dependencies: false

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
2 changes: 1 addition & 1 deletion .github/workflows/hacs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
- name: HACS validation
uses: "hacs/action@main"
with:
category: "appdaemon"
category: "appdaemon"
2 changes: 1 addition & 1 deletion .github/workflows/update-license.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
fetch-depth: 0
- uses: FantasticFiasco/action-update-license-year@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,4 @@ dmypy.json
.idea

# Ignoring Pipfile.lock since we support different python versions
Pipfile.lock
Pipfile.lock
51 changes: 25 additions & 26 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
fail_fast: true
repos:
- repo: local
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: debug-statements
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
name: isort
entry: pipenv run isort
language: python
types: [python]
args: []
require_serial: false
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
name: black
entry: pipenv run black
language: python
types: [python]
- repo: https://github.com/asottile/pyupgrade
rev: v2.32.0
hooks:
- id: pyupgrade
args: [--py37-plus, --keep-mock]
- repo: https://gitlab.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
name: flake8
entry: pipenv run flake8
language: python
types: [python]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.942
hooks:
- id: mypy
name: mypy
entry: pipenv run mypy --install-types --non-interactive
language: python
types: [python]
- id: pytest
name: pytest
entry: pipenv run pytest
language: python
files: "(.*.py)|apps/controllerx/*|tests/*"
pass_filenames: false
args: []
additional_dependencies: [types-PyYAML, types-mock]
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.ht
[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
https://www.contributor-covenant.org/faq
38 changes: 8 additions & 30 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,44 +30,30 @@ Note that this project will only accept the mapping that the original controller

This is a [commit](https://github.com/xaviml/controllerx/commit/38ee4b03ac31bf966523cc63c0200567f912f201) of a complete example of adding a new device, it can be used as a reference.

## Imports
## Styling

Run the following to fix imports order:
This repository uses [pre-commit](https://pre-commit.com/) which allows us to keep some code standards by using several tools (isort, black, mypy, flake8, etc). For more detail check `.pre-commit-config.yaml` file.

```shell
pipenv run isort apps/controllerx/ tests/
```

## Format

Run the following to fix formatting:
The following command can be executed to run all checkers for all files:

```shell
pipenv run black apps/controllerx/ tests/
pre-commit run --all-files
```

## Typing

Run the following to check consistency in the typings:
If you want to run it for ust the staged files:

```shell
pipenv run mypy apps/controllerx/ tests/
pre-commit run
```

## Linting

Run the following to check for stylings:

```shell
pipenv run flake8 apps/controllerx/ tests/
```
If `pre-commit` was installed into git hooks (`pre-commit install`), it will run the checkers before the commit.

## Test

Run the following command for the tests:

```shell
pipenv run pytest --cov=apps
pytest
```

or the following to get a report of the missing lines to be tested:
Expand All @@ -76,14 +62,6 @@ or the following to get a report of the missing lines to be tested:
pytest --cov-report term-missing --cov=apps
```

## Pre-commit

Once you have the code ready, pre-commit will run some checks to make sure the code follows the format and the tests did not break. If you want to run the check for all files at any point, run:

```shell
pipenv run pre-commit run --all-files
```

## Commiting

You can use the tool `commitizen` to commit based in a standard. If you are in the virtual environment, you can run `cz commit` and answer the questions to commit.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
4 changes: 0 additions & 4 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
black = "==22.3.0"
pytest = "==7.1.1"
pytest-asyncio = "==0.18.3"
pytest-cov = "==3.0.0"
Expand All @@ -13,9 +12,6 @@ pytest-timeout = "==2.1.0"
mock = "==4.0.3"
pre-commit = "==2.18.1"
commitizen = "==2.23.0"
mypy = "==0.942"
flake8 = "==4.0.1"
isort = "==5.10.1"
controllerx = {path = ".", editable = true}

[packages]
Expand Down
2 changes: 1 addition & 1 deletion apps/controllerx/cx_core/stepper/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import abc
from dataclasses import dataclass
from typing import Optional

from attr import dataclass
from cx_const import Number, StepperDir


Expand Down
6 changes: 2 additions & 4 deletions apps/controllerx/cx_core/type_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,8 @@ def _check_domain(self, entity: Entity) -> None:
if self.contains_templating(entity.name):
return
same_domain = all(
(
any(elem.startswith(domain + ".") for domain in self.domains)
for elem in entity.entities
)
any(elem.startswith(domain + ".") for domain in self.domains)
for elem in entity.entities
)
if not same_domain:
if entity.is_group:
Expand Down
10 changes: 2 additions & 8 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,8 @@ stages:
displayName: Lock dependencies
- script: pipenv install --system --deploy --dev
displayName: Install dependencies
- script: isort apps/controllerx/ tests/ --check
displayName: Organize imports (isort)
- script: black apps/controllerx/ tests/ --check
displayName: Formatter (black)
- script: flake8 apps/controllerx/ tests/
displayName: Styling (flake8)
- script: mypy --install-types --non-interactive apps/controllerx/ tests/
displayName: Typing (mypy)
- script: pre-commit run --all-files --show-diff-on-failure
displayName: Run pre-commit
- script: pytest tests --doctest-modules --junitxml=junit/test-results.xml --cov=apps --cov-report=xml --cov-report=html
displayName: Tests (pytest)
- task: PublishCodeCoverageResults@1
Expand Down
4 changes: 2 additions & 2 deletions docs/_data/controllers/324131092621.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ integrations:

note: >-
In case of working with <strong>z2m</strong> and wanting to use the multiclick functionality, then
you need to make sure to remove from the device specific (devices.yaml) the
you need to make sure to remove from the device specific (devices.yaml) the
`multiple_press_timeout` option.
In case of <strong>deCONZ</strong>, all the click actions are mapped with X002 actions, so when the
In case of <strong>deCONZ</strong>, all the click actions are mapped with X002 actions, so when the
button is released after being clicked.
2 changes: 1 addition & 1 deletion docs/_data/controllers/929003017102.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ integrations:
- "2003 → Release right"
note: >-
This controller has 4 modes and depending on which one is used, it will trigger one action or another: single_rocker, single_push_button, dual_rocker, dual_push_button.
You can read more about it in these threads: <a href="https://github.com/dresden-elektronik/deconz-rest-plugin/issues/4566">deconz</a> and
You can read more about it in these threads: <a href="https://github.com/dresden-elektronik/deconz-rest-plugin/issues/4566">deconz</a> and
<a href="https://github.com/Koenkk/zigbee-herdsman-converters/issues/2393">zigbee2mqtt</a>.
2 changes: 1 addition & 1 deletion docs/_data/controllers/E1524_E1810.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: E1524/E1810 (IKEA)
device_support:
device_support:
- type: Light
domain: light
controller: E1810Controller
Expand Down
2 changes: 1 addition & 1 deletion docs/_data/controllers/E1744.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: E1744 (IKEA)
device_support:
device_support:
- type: Light
domain: light
controller: E1744LightController
Expand Down
2 changes: 1 addition & 1 deletion docs/_data/controllers/ICTCG1.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: ICTCG1 (IKEA)
device_support:
device_support:
- type: Light
domain: light
controller: ICTCG1Controller
Expand Down
2 changes: 1 addition & 1 deletion docs/_data/controllers/IM6001-BTP01.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: IM6001-BTP01 (SmartThings)
device_support:
device_support:
- type: Light
domain: light
controller: SmartThingsButtonLightController
Expand Down
2 changes: 1 addition & 1 deletion docs/_data/controllers/LZL4BWHL01.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ integrations:
- "step_with_on_off_0_30_6 → Arrow up held"
- "step_1_30_6 → Arrow down held"
- "move_to_level_with_on_off_0_4 → Bottom button pressed"
- "stop → Arrow released"
- "stop → Arrow released"
6 changes: 3 additions & 3 deletions docs/_data/controllers/MFKZQ01LM.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ integrations:
- "rotate_left → Rotate cube to left"
- "rotate_right → Rotate cube to right"
note: >-
This controller does not have a self-explained way to use it since its main
purpose is to be customized, this is why we recommend to customize it with
<a href="/controllerx/advanced/custom-controllers">custom mapping</a>.
This controller does not have a self-explained way to use it since its main
purpose is to be customized, this is why we recommend to customize it with
<a href="/controllerx/advanced/custom-controllers">custom mapping</a>.
deCONZ integration should be added with <a href="/controllerx/others/integrations#deconz">type gesture</a>.
2 changes: 1 addition & 1 deletion docs/_data/controllers/PJ2-2B.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ device_support:
- "Top button → Play/Pause"
- "Bottom button → Next track"
note: >-
For the State integration, it requires the <a href="https://github.com/upsert/lutron-caseta-pro">LutronCasetaPro</a>
For the State integration, it requires the <a href="https://github.com/upsert/lutron-caseta-pro">LutronCasetaPro</a>
CUSTOM integration by upsert. THIS WILL NOT WORK with the default Lutron Caseta integration.
All Lutron Caseta Pro Pico remotes supported by LutronCasetaPro are supported using this
controller type except for the 4-button PJ2-4B remotes which is separate.
Expand Down
2 changes: 1 addition & 1 deletion docs/_data/controllers/PJ2-2BRL.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ device_support:
- "Arrow down button → Volume down"
- "Bottom button → Next track"
note: >-
For the State integration, it requires the <a href="https://github.com/upsert/lutron-caseta-pro">LutronCasetaPro</a>
For the State integration, it requires the <a href="https://github.com/upsert/lutron-caseta-pro">LutronCasetaPro</a>
CUSTOM integration by upsert. THIS WILL NOT WORK with the default Lutron Caseta integration.
All Lutron Caseta Pro Pico remotes supported by LutronCasetaPro are supported using this
controller type except for the 4-button PJ2-4B remotes which is separate.
Expand Down
2 changes: 1 addition & 1 deletion docs/_data/controllers/PJ2-3BRL.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ device_support:
- "Arrow down button → Volume down"
- "Bottom button → Next track"
note: >-
For the State integration, it requires the <a href="https://github.com/upsert/lutron-caseta-pro">LutronCasetaPro</a>
For the State integration, it requires the <a href="https://github.com/upsert/lutron-caseta-pro">LutronCasetaPro</a>
CUSTOM integration by upsert. THIS WILL NOT WORK with the default Lutron Caseta integration.
All Lutron Caseta Pro Pico remotes supported by LutronCasetaPro are supported using this
controller type except for the 4-button PJ2-4B remotes which is separate.
Expand Down
2 changes: 1 addition & 1 deletion docs/_data/controllers/PJ2-4B.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ device_support:
- "Third button → Volume down"
- "Bottom button → Next track"
note: >-
For the State integration, it requires the <a href="https://github.com/upsert/lutron-caseta-pro">LutronCasetaPro</a>
For the State integration, it requires the <a href="https://github.com/upsert/lutron-caseta-pro">LutronCasetaPro</a>
CUSTOM integration by upsert. THIS WILL NOT WORK with the default Lutron Caseta integration.
integrations:
Expand Down
2 changes: 1 addition & 1 deletion docs/_data/controllers/PTM215X.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: PTM215X (EnOcean - Philips)
device_support:
device_support:
- type: Light
domain: light
controller: PTM215XLightController
Expand Down
2 changes: 1 addition & 1 deletion docs/_data/controllers/TERNCY-PP01.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ integrations:
- "button_double → 2 clicks"
- "button_triple → 3 clicks"
- "button_quadruple → 4 clicks"
- "button_quintuple → 5 clicks"
- "button_quintuple → 5 clicks"
2 changes: 1 addition & 1 deletion docs/_data/controllers/TERNCY-SD01.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ integrations:
- "button_quadruple → 4 clicks"
- "button_quintuple → 5 clicks"
- "rotate_left → Rotate knob to the left"
- "rotate_right → Rotate knob to the right"
- "rotate_right → Rotate knob to the right"
2 changes: 1 addition & 1 deletion docs/_data/controllers/TS0043.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ note: >-
So you can include the `actions` parameter to include the actions needed,
or use the `mapping` attribute to define a <a href="/controllerx/advanced/custom-controllers">custom mapping</a>.
You can check <a href="https://github.com/xaviml/controllerx/issues/18#issuecomment-582535634">here</a> for reference.
Also, this controller support hold action, but not release. This means that there is not
Also, this controller support hold action, but not release. This means that there is not
smooth brightness changes when holding, just step by step everytime is held.
2 changes: 1 addition & 1 deletion docs/_data/controllers/TS0044.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ note: >-
So you can include the `actions` parameter to include the actions needed,
or use the `mapping` attribute to define a <a href="/controllerx/advanced/custom-controllers">custom mapping</a>.
You can check <a href="https://github.com/xaviml/controllerx/issues/18#issuecomment-582535634">here</a> for reference.
Also, this controller support hold action, but not release. This means that there is not
Also, this controller support hold action, but not release. This means that there is not
smooth brightness changes when holding, just step by step everytime is held.
2 changes: 1 addition & 1 deletion docs/_data/controllers/TS0044F.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ note: >-
So you can include the `actions` parameter to include the actions needed,
or use the `mapping` attribute to define a <a href="/controllerx/advanced/custom-controllers">custom mapping</a>.
You can check <a href="https://github.com/xaviml/controllerx/issues/18#issuecomment-582535634">here</a> for reference.
Also, this controller doesn't support hold action. This means that there is not
Also, this controller doesn't support hold action. This means that there is not
smooth brightness changes when holding, just step by step everytime it's pressed.
2 changes: 1 addition & 1 deletion docs/_data/controllers/WXCJKG11LM.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ integrations:
- "button_2_double → Double click right button"
- "button_2_triple → Triple click right button"
- "button_2_hold → Hold right button"
- "button_2_release → Release right button"
- "button_2_release → Release right button"
4 changes: 2 additions & 2 deletions docs/_data/controllers/WXKG02LM.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ integrations:
- "right_double → Double click on right"
- "right_long press → Long click on right"
note: >-
Note that all actions related to both, left and right, do the same.
Note that all actions related to both, left and right, do the same.
This is because ControllerX is design to control just one entity (light or media player).
So you can include the `actions` parameter to include the actions needed.
You can check <a href="https://github.com/xaviml/controllerx/issues/18#issuecomment-582535634">here</a> for reference.
Also, this controller support hold action, but not release. This means that there is not
Also, this controller support hold action, but not release. This means that there is not
smooth brightness changes when holding, just step by step everytime is held.
2 changes: 1 addition & 1 deletion docs/_data/controllers/WXKG06LM.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ integrations:
- "1004 → Double click"
- "1001 → Long click"
note: >-
This controller support hold action, but not release. This means that there is not
This controller support hold action, but not release. This means that there is not
smooth brightness changes when holding, just step by step everytime is held.

0 comments on commit 6cb4810

Please sign in to comment.