Skip to content

Commit ff6def0

Browse files
committed
Add mypy and pylint workflows
1 parent c2e4ddc commit ff6def0

File tree

6 files changed

+75
-5
lines changed

6 files changed

+75
-5
lines changed

.github/workflows/mypy.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Mypy type checking
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- main
9+
jobs:
10+
check:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/[email protected]
14+
with:
15+
fetch-depth: 0
16+
- name: Set up Python 3.8
17+
uses: actions/[email protected]
18+
with:
19+
python-version: 3.8
20+
- uses: actions/[email protected]
21+
with:
22+
path: ~/.cache/pip
23+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
24+
restore-keys: |
25+
${{ runner.os }}-pip-
26+
- name: Install apt deps
27+
run: sudo apt-get update && sudo apt-get install -qq -y libenchant-dev libxml2-dev libxslt1-dev
28+
- name: Install dependencies
29+
run: pip install -Ur requirements-dev.txt
30+
- name: Test with mypy
31+
run: pre-commit run mypy --all

.github/workflows/pylint.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Pylint analysis
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- main
9+
jobs:
10+
check:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/[email protected]
14+
with:
15+
fetch-depth: 0
16+
- name: Set up Python 3.8
17+
uses: actions/[email protected]
18+
with:
19+
python-version: 3.8
20+
- uses: actions/[email protected]
21+
with:
22+
path: ~/.cache/pip
23+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
24+
restore-keys: |
25+
${{ runner.os }}-pip-
26+
- name: Install apt deps
27+
run: sudo apt-get update && sudo apt-get install -qq -y libenchant-dev libxml2-dev libxslt1-dev
28+
- name: Install dependencies
29+
run: pip install -Ur requirements-dev.txt
30+
- name: Run pylint
31+
run: pre-commit run pylint --all

.mypy.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ strict_optional = False
77
ignore_missing_imports = True
88
check_untyped_defs = True
99
show_error_codes = True
10+
warn_unused_ignores = True
11+
warn_redundant_casts = True
12+
;strict_equality = True

plugins/profiling.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
import signal
32
import sys
43
import threading
@@ -123,12 +122,17 @@ def pympler_diff():
123122
return "Printed to console"
124123

125124

125+
try:
126+
SIGUSR1 = getattr(signal, "SIGUSR1")
127+
except AttributeError:
128+
SIGUSR1 = None
129+
126130
# # Provide an easy way to get a threaddump, by using SIGUSR1 (only on POSIX systems)
127-
if os.name == "posix":
131+
if SIGUSR1 is not None:
128132
# The handler is called with two arguments: the signal number and the current stack frame
129133
# These parameters should NOT be removed
130134
# noinspection PyUnusedLocal
131135
def debug(sig, frame):
132136
print(get_thread_dump())
133137

134-
signal.signal(signal.SIGUSR1, debug) # Register handler
138+
signal.signal(SIGUSR1, debug) # Register handler

plugins/tvdb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ class Holder(Generic[T]):
209209
"""
210210

211211
def __init__(self) -> None:
212-
self._item = None # type: Optional[T]
212+
self._item: Optional[T] = None
213213
self._set = False
214214

215215
def set(self, item: T) -> None:
@@ -245,7 +245,7 @@ def get(self) -> T:
245245
if not self._set:
246246
raise MissingItem()
247247

248-
return cast(T, self._item)
248+
return self._item
249249

250250

251251
class LazyCollection(Sized, Iterable[T], Container[T]):

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
coverage == 6.0.1
22
freezegun == 1.1.0
33
mypy == 0.910
4+
pre-commit == 2.15.0
45
pylint == 2.11.1
56
pytest == 6.2.5
67
pytest-asyncio == 0.15.1

0 commit comments

Comments
 (0)