Skip to content

Commit

Permalink
Merge pull request #281 from sdb9696/fix_ci
Browse files Browse the repository at this point in the history
Fix ci to use up to date python versions and include pre-commit-config
  • Loading branch information
tchellomello committed Sep 11, 2023
2 parents 6c676ce + 8e084cb commit 9efa9da
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 24 deletions.
50 changes: 39 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,44 @@
name: CI

on:
- push
push:
pull_request:
branches: ["master"]

jobs:
ci:
linting:
name: "Perform linting checks"
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
steps:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v2"
with:
python-version: "${{ matrix.python-version }}"
- name: "Install dependencies"
run: |
python -m pip install --upgrade pip
pip install -U tox
- name: Lint with tox
run: |
tox
env:
TOXENV: lint

tests:
name: tests
needs: linting
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python-version:
- 3.6
- 3.7
- 3.8
- "3.8"
- "3.9"
- "3.10"
- "3.11"
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -26,12 +52,14 @@ jobs:
- name: Prepare toxenv
id: toxenv
run: |
if [[ '${{ matrix.python-version }}' == '3.6' ]]; then
echo "::set-output name=toxenv::py36"
elif [[ '${{ matrix.python-version }}' == '3.7' ]]; then
echo "::set-output name=toxenv::py37"
if [[ '${{ matrix.python-version }}' == '3.8' ]]; then
echo "::set-output name=toxenv::py38"
elif [[ '${{ matrix.python-version }}' == '3.9' ]]; then
echo "::set-output name=toxenv::py39"
elif [[ '${{ matrix.python-version }}' == '3.10' ]]; then
echo "::set-output name=toxenv::py310"
else
echo "::set-output name=toxenv::lint"
echo "::set-output name=toxenv::py311"
fi
- name: Test with tox
run: |
Expand All @@ -42,6 +70,6 @@ jobs:
run: |
coveralls --service=github
# Only report coverage on latest Python version and skip on prior failures
if: ${{ success() && matrix.python-version == '3.7' }}
if: ${{ success() && matrix.python-version == '3.11' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
repos:
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8

- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
require_serial: true
files: ^ring_doorbell/
args:
- --rcfile=pylintrc

- repo: https://github.com/python/black
rev: 23.3.0
hooks:
- id: black
args:
- --check
12 changes: 5 additions & 7 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,21 @@ reports=no
# locally-disabled - it spams too much
# duplicate-code - unavoidable
# cyclic-import - doesn't test if both import on load
# abstract-class-little-used - prevents from setting right foundation
# abstract-class-not-used - is flaky, should not show up but does
# unused-argument - generic callbacks and setup methods create a lot of warnings
# global-statement - used for the on-demand requirement installation
# redefined-variable-type - this is Python, we're duck typing!
# too-many-* - are not enforced for the sake of readability
# too-few-* - same as too-many-*
# abstract-method - with intro of async there are always methods missing
# consider-using-f-string - not updating legacy string formats at the moment

disable=
format,
locally-disabled,
duplicate-code,
cyclic-import,
abstract-class-little-used,
abstract-class-not-used,
unused-argument,
global-statement,
redefined-variable-type,
too-many-arguments,
too-many-branches,
too-many-instance-attributes,
Expand All @@ -34,7 +30,9 @@ disable=
too-many-statements,
too-many-lines,
too-few-public-methods,
abstract-method
abstract-method,
consider-using-f-string,
import-error,

[EXCEPTIONS]
overgeneral-exceptions=Exception
overgeneral-exceptions=builtins.Exception
5 changes: 2 additions & 3 deletions ring_doorbell/doorbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def existing_doorbell_type(self, value):
1: Digital
2: Not Present
"""
# pylint:disable=consider-iterating-dictionary
if value not in DOORBELL_EXISTING_TYPE.keys():
_LOGGER.error("%s", MSG_EXISTING_TYPE)
return False
Expand Down Expand Up @@ -177,7 +178,6 @@ def existing_doorbell_type_enabled(self):
def existing_doorbell_type_enabled(self, value):
"""Enable/disable the existing doorbell if Digital/Mechanical."""
if self.existing_doorbell_type:

if not isinstance(value, bool):
_LOGGER.error("%s", MSG_BOOLEAN_REQUIRED)
return None
Expand Down Expand Up @@ -207,7 +207,6 @@ def existing_doorbell_type_duration(self):
def existing_doorbell_type_duration(self, value):
"""Set duration for Digital chime."""
if self.existing_doorbell_type:

if not (
(isinstance(value, int))
and (DOORBELL_VOL_MIN <= value <= DOORBELL_VOL_MAX)
Expand Down Expand Up @@ -251,6 +250,7 @@ def history(
original_limit = limit

# set cap for max queries
# pylint:disable=consider-using-min-builtin
if retry > 10:
retry = 10

Expand Down Expand Up @@ -349,7 +349,6 @@ def recording_download(
# Video download needs a longer timeout to get the large video file
req = self._ring.query(url, timeout=timeout)
if req and req.status_code == 200:

if filename:
if os.path.isfile(filename) and not override:
_LOGGER.error("%s", FILE_EXISTS.format(filename))
Expand Down
1 change: 1 addition & 0 deletions ring_doorbell/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class RingGeneric(object):
"""Generic Implementation for Ring Chime/Doorbell."""

# pylint: disable=redefined-builtin
# pylint:disable=invalid-name
def __init__(self, ring, id):
"""Initialize Ring Generic."""
self._ring = ring
Expand Down
2 changes: 1 addition & 1 deletion ring_doorbell/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
class RingLightGroup:
"""Implementation for RingLightGroup."""

# pylint:disable=invalid-name
# pylint: disable=redefined-builtin
def __init__(self, ring, id):
"""Initialize Ring Generic."""
Expand Down Expand Up @@ -60,7 +61,6 @@ def model(self):
"""Return Ring device model name."""
return "Light Group"

# pylint:disable=no-self-use
def has_capability(self, capability):
"""Return if device has specific capability."""
if capability == "light":
Expand Down
1 change: 0 additions & 1 deletion scripts/ringcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def _format_filename(event):


def main():

parser = argparse.ArgumentParser(
description="Ring Doorbell",
epilog="https://github.com/tchellomello/python-ring-doorbell",
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py36, py37, lint
envlist = py38, py39, py310, py311, lint
skip_missing_interpreters = True

[testenv]
Expand Down

0 comments on commit 9efa9da

Please sign in to comment.