Skip to content

Commit 2c64db5

Browse files
committed
Add pre-commit
1 parent e1dd66d commit 2c64db5

File tree

7 files changed

+86
-13
lines changed

7 files changed

+86
-13
lines changed

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
max-line-length = 100
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: CI/CQ
2+
3+
on:
4+
pull_request:
5+
types: ["opened", "synchronize", "reopened"]
6+
7+
jobs:
8+
codechecks:
9+
name: Code Quality
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
python-version: ['3.10', '3.11']
14+
steps:
15+
- name: Checkout Repository
16+
uses: actions/checkout@v3
17+
18+
- name: Set Up Python-${{ matrix.python-version }}
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
23+
- name: Pre Commit Checks
24+
uses: pre-commit/[email protected]
25+
26+
- name: Analysis (git diff)
27+
if: failure()
28+
run: git diff

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Compiled python code.
2+
*.pyc

.pre-commit-config.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# configuration for pre-commit git hooks
2+
3+
repos:
4+
- repo: https://github.com/asottile/reorder_python_imports
5+
rev: v3.9.0
6+
hooks:
7+
- id: reorder-python-imports
8+
- repo: https://github.com/pre-commit/pre-commit-hooks
9+
rev: v4.4.0
10+
hooks:
11+
- id: trailing-whitespace
12+
- id: end-of-file-fixer
13+
- id: check-yaml
14+
- id: debug-statements
15+
- repo: https://github.com/asottile/pyupgrade
16+
rev: v3.3.0
17+
hooks:
18+
- id: pyupgrade
19+
args: [--py38-plus]
20+
- repo: https://github.com/psf/black
21+
rev: 22.10.0
22+
hooks:
23+
- id: black
24+
- repo: https://github.com/pycqa/flake8
25+
rev: 6.0.0
26+
hooks:
27+
- id: flake8

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
SOFTWARE.

custom_components/feedparser/sensor.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
"""Feedparser sensor"""
22
from __future__ import annotations
33

4-
import asyncio
54
import re
65
from datetime import timedelta
76

7+
import feedparser
88
import homeassistant.helpers.config_validation as cv
9+
import homeassistant.util.dt as dt
910
import voluptuous as vol
1011
from dateutil import parser
11-
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
12-
from homeassistant.const import CONF_NAME, CONF_SCAN_INTERVAL
12+
from homeassistant.components.sensor import PLATFORM_SCHEMA
13+
from homeassistant.components.sensor import SensorEntity
14+
from homeassistant.const import CONF_NAME
15+
from homeassistant.const import CONF_SCAN_INTERVAL
1316
from homeassistant.core import HomeAssistant
1417
from homeassistant.helpers.entity_platform import AddEntitiesCallback
15-
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
16-
import homeassistant.util.dt as dt
17-
18-
import feedparser
18+
from homeassistant.helpers.typing import ConfigType
19+
from homeassistant.helpers.typing import DiscoveryInfoType
1920

2021
__version__ = "0.1.11"
2122

@@ -25,7 +26,7 @@
2526

2627
CONF_FEED_URL = "feed_url"
2728
CONF_DATE_FORMAT = "date_format"
28-
CONF_LOCAL_TIME = "local_time"
29+
CONF_LOCAL_TIME = "local_time"
2930
CONF_INCLUSIONS = "inclusions"
3031
CONF_EXCLUSIONS = "exclusions"
3132
CONF_SHOW_TOPN = "show_topn"
@@ -46,7 +47,6 @@
4647
)
4748

4849

49-
"""@asyncio.coroutine"""
5050
async def async_setup_platform(
5151
hass: HomeAssistant,
5252
config: ConfigType,
@@ -129,9 +129,7 @@ def update(self):
129129
if "image" in self._inclusions and "image" not in entry_value.keys():
130130
images = []
131131
if "summary" in entry.keys():
132-
images = re.findall(
133-
r"<img.+?src=\"(.+?)\".+?>", entry["summary"]
134-
)
132+
images = re.findall(r"<img.+?src=\"(.+?)\".+?>", entry["summary"])
135133
if images:
136134
entry_value["image"] = images[0]
137135
else:

pyproject.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[tool.black]
2+
line-length = 100
3+
skip-string-normalization = true
4+
include = '\.pyi?$'
5+
exclude = '''
6+
/(
7+
\.git
8+
| \.hg
9+
| \.mypy_cache
10+
| \.venv
11+
| _build
12+
| buck-out
13+
| build
14+
| dist
15+
)/
16+
'''

0 commit comments

Comments
 (0)