Skip to content

Commit d281777

Browse files
authored
Merge pull request #424 from TotallyNotRobots/add-pylint-mypy-actions
Add mypy and pylint workflows
2 parents c2e4ddc + b637335 commit d281777

File tree

9 files changed

+81
-7
lines changed

9 files changed

+81
-7
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ name: "CodeQL"
1313

1414
on:
1515
push:
16-
branches: [ main ]
16+
branches: [main]
1717
pull_request:
1818
# The branches below must be a subset of the branches above
19-
branches: [ main ]
19+
branches: [main]
2020
schedule:
21-
- cron: '17 23 * * 6'
21+
- cron: '17 23 * * 6'
2222

2323
jobs:
2424
analyze:
@@ -32,7 +32,7 @@ jobs:
3232
strategy:
3333
fail-fast: false
3434
matrix:
35-
language: [ 'python' ]
35+
language: ['python']
3636
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
3737
# Learn more:
3838
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

.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

.pylintrc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ confidence=
6262
# --disable=W".
6363
disable=invalid-name,
6464
missing-docstring,
65+
consider-using-f-string,
66+
consider-using-dict-items,
67+
consider-using-with,
68+
consider-using-min-builtin,
69+
arguments-renamed,
70+
use-maxsplit-arg,
71+
consider-iterating-dictionary,
6572
redefined-outer-name,
6673
unused-argument,
6774
broad-except,
@@ -87,7 +94,7 @@ disable=invalid-name,
8794
# either give multiple identifier separated by comma (,) or put this option
8895
# multiple time (only on the command line, not in the configuration file where
8996
# it should appear only once). See also the "--disable" option for examples.
90-
enable=
97+
enable=c-extension-no-member
9198

9299

93100
[REPORTS]

plugins/tvdb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def mock_api_keys():
9292
mock_bot = MagicMock()
9393
try:
9494
bot.set(mock_bot)
95+
# pylint: disable=no-member
9596
mock_bot.config.get_api_key.return_value = "APIKEY"
9697
yield mock_bot
9798
finally:

tests/core_tests/irc_client_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
import pytest
88

9-
import cloudbot.clients.irc as irc
109
from cloudbot.client import ClientConnectError
10+
from cloudbot.clients import irc
1111
from cloudbot.event import Event, EventType
1212
from cloudbot.util import async_util
1313
from tests.util.async_mock import AsyncMock

0 commit comments

Comments
 (0)