Skip to content

Commit 8edecc1

Browse files
committed
The package is now fully typed
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
1 parent e3f4a93 commit 8edecc1

63 files changed

Lines changed: 1634 additions & 323 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.pre-commit-config.yaml

Lines changed: 58 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,29 @@ repos:
3636
language: system
3737
# <---- Local Hooks ------------------------------------------------------------------------------------------------
3838

39+
# ----- Remove Typing - Py3.5 Support ---------------------------------------------------------------------------->
40+
- repo: https://github.com/s0undt3ch/downgrade-source
41+
rev: v2.1.0
42+
hooks:
43+
- id: downgrade-source
44+
name: Downgrade source code into a separate package to support Py3.5
45+
files: ^src/.*\.py$
46+
exclude: ^src/pytestskipmarkers/((__init__|version|utils/__init__)\.py|downgraded/.*\.py)$
47+
args:
48+
- --target-version=3.5
49+
- --pkg-path=src/pytestskipmarkers
50+
- --skip-checker=nounusableimports
51+
- --skip-checker=nostarimports
52+
# <---- Remove Typing - Py3.5 Support -----------------------------------------------------------------------------
53+
3954
# ----- Formatting ------------------------------------------------------------------------------------------------>
4055
- repo: https://github.com/asottile/pyupgrade
4156
rev: v2.29.0
4257
hooks:
4358
- id: pyupgrade
4459
name: Rewrite Code to be Py3.5+
4560
args: [--py3-plus]
46-
exclude: (^src/pytestskipmarkers/utils/saltext/.*\.py)
47-
48-
- repo: https://github.com/hakancelik96/unimport
49-
rev: "0.9.2"
50-
hooks:
51-
- id: unimport
52-
name: Remove unused imports
53-
args: [--remove]
54-
exclude: ^(docs/.*\.py|src/pytestskipmarkers/(cli|daemons)/__init__\.py)$
61+
exclude: ^src/pytestskipmarkers/downgraded/.*\.py$
5562

5663
- repo: https://github.com/asottile/reorder_python_imports
5764
rev: v2.6.0
@@ -61,42 +68,22 @@ repos:
6168
--py3-plus,
6269
--application-directories=.:src:examples/echo-extension/src
6370
]
64-
exclude: src/pytestskipmarkers/version.py
71+
exclude: ^src/pytestskipmarkers/(version.py|downgraded/.*)$
6572

6673
- repo: https://github.com/psf/black
6774
rev: 21.9b0
6875
hooks:
6976
- id: black
7077
args: [-l 100]
71-
exclude: src/pytestskipmarkers/version.py
78+
exclude: ^src/pytestskipmarkers/(version.py|downgraded/.*)$
7279

7380
- repo: https://github.com/asottile/blacken-docs
7481
rev: v1.11.0
7582
hooks:
7683
- id: blacken-docs
7784
args: [--skip-errors]
78-
files: ^(docs/.*\.rst|src/pytestskipmarkers/.*\.py)$
85+
files: ^(.*\.rst|docs/.*\.rst|src/pytestskipmarkers/.*\.py)$
7986
additional_dependencies: [black==21.9b0]
80-
81-
- repo: https://github.com/pre-commit/mirrors-pylint
82-
rev: v3.0.0a4
83-
hooks:
84-
- id: pylint
85-
name: PyLint
86-
args: [--output-format=parseable, --rcfile=.pylintrc]
87-
exclude: src/pytestskipmarkers/version.py
88-
additional_dependencies:
89-
- pyenchant
90-
91-
- repo: https://github.com/pre-commit/mirrors-mypy
92-
rev: v0.910
93-
hooks:
94-
- id: mypy
95-
files: ^(src/|tests/).*\.py$
96-
args: []
97-
additional_dependencies:
98-
- types-attrs
99-
- types-setuptools
10087
# <---- Formatting -------------------------------------------------------------------------------------------------
10188

10289
# ----- Security -------------------------------------------------------------------------------------------------->
@@ -120,3 +107,42 @@ repos:
120107
args: [--silent, -lll, --skip, B701]
121108
files: ^tests/.*
122109
# <---- Security ---------------------------------------------------------------------------------------------------
110+
111+
# ----- Code Analysis --------------------------------------------------------------------------------------------->
112+
- repo: https://github.com/pycqa/flake8
113+
rev: '4.0.1'
114+
hooks:
115+
- id: flake8
116+
exclude: ^(src/pytestskipmarkers/(downgraded/.*|version\.py)|\.pre-commit-hooks/.*\.py)$
117+
additional_dependencies:
118+
- flake8-mypy-fork
119+
- flake8-docstrings
120+
- flake8-typing-imports
121+
122+
- repo: https://github.com/pre-commit/mirrors-mypy
123+
rev: v0.931
124+
hooks:
125+
- id: mypy
126+
name: Run mypy against source
127+
files: ^src/.*\.py$
128+
exclude: ^src/pytestskipmarkers/(downgraded/.*|utils/(socket|time)\.py)$
129+
args: [--strict]
130+
additional_dependencies:
131+
- attrs
132+
- types-attrs
133+
- types-setuptools
134+
135+
- repo: https://github.com/pre-commit/mirrors-mypy
136+
rev: v0.931
137+
hooks:
138+
- id: mypy
139+
name: Run mypy against tests
140+
files: ^tests/.*\.py$
141+
exclude: ^src/pytestskipmarkers/(downgraded/.*|utils/(socket|time)\.py)$
142+
args: []
143+
additional_dependencies:
144+
- pytest
145+
- attrs
146+
- types-attrs
147+
- types-setuptools
148+
# <---- Code Analysis ----------------------------------------------------------------------------------------------

.pylint-spelling-words

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ lsof
3939
macos
4040
mtime
4141
namespace
42+
namespaced
4243
netbsd
44+
noqa
4345
nox
4446
openbsd
4547
os

.pylintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ disable=R,
113113
import-outside-toplevel,
114114
wrong-import-position,
115115
wrong-import-order,
116-
missing-whitespace-after-comma
116+
missing-whitespace-after-comma,
117+
consider-using-f-string
117118

118119
# Disabled:
119120
# R* [refactoring suggestions & reports]

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Once installed, you can now skip some tests with some simple pytest markers, for
6868
6969
import pytest
7070
71+
7172
@pytest.mark.skip_unless_on_linux
7273
def test_on_linux():
7374
assert True

changelog/8.improvement.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The plugin is now fully typed

docs/ref/pytestskipmarkers/utils/markers.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
PyTest Markers related utilities
2+
================================
3+
14
.. automodule:: pytestskipmarkers.utils.markers
25
:members:
36
:show-inheritance:

docs/ref/pytestskipmarkers/utils/platform.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
Platform related utilities
2+
==========================
3+
14
.. automodule:: pytestskipmarkers.utils.platform
25
:members:
36
:show-inheritance:

docs/ref/pytestskipmarkers/utils/ports.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
Ports related utility functions
2+
===============================
3+
14
.. automodule:: pytestskipmarkers.utils.ports
25
:members:
36
:show-inheritance:

noxfile.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
IS_DARWIN = sys.platform.lower().startswith("darwin")
2121

2222
if IS_WINDOWS:
23-
COVERAGE_FAIL_UNDER_PERCENT = 92
23+
COVERAGE_FAIL_UNDER_PERCENT = 91
2424
elif IS_DARWIN:
25-
COVERAGE_FAIL_UNDER_PERCENT = 95
25+
COVERAGE_FAIL_UNDER_PERCENT = 93
2626
else:
27-
COVERAGE_FAIL_UNDER_PERCENT = 95
27+
COVERAGE_FAIL_UNDER_PERCENT = 93
2828

2929
# Be verbose when running under a CI context
3030
PIP_INSTALL_SILENT = (
@@ -116,7 +116,7 @@ def session_run_always(session, *command, **kwargs):
116116
@nox.session(python=("3", "3.5", "3.6", "3.7", "3.8", "3.9"))
117117
def tests(session):
118118
"""
119-
Run tests
119+
Run tests.
120120
"""
121121
env = {}
122122
if SKIP_REQUIREMENTS_INSTALL is False:
@@ -238,7 +238,7 @@ def _lint(session, rcfile, flags, paths):
238238
sys.stdout.flush()
239239
if pylint_report_path:
240240
# Write report
241-
with open(pylint_report_path, "w") as wfh:
241+
with open(pylint_report_path, "w", encoding="utf-8") as wfh:
242242
wfh.write(contents)
243243
session.log("Report file written to %r", pylint_report_path)
244244
stdout.close()
@@ -258,7 +258,7 @@ def lint_code(session):
258258
"""
259259
Run PyLint against the code. Set PYLINT_REPORT to a path to capture output.
260260
"""
261-
flags = ["--disable=I"]
261+
flags = ["--disable=I", "--ignore-paths=src/pytestskipmarkers/downgraded/.*"]
262262
if session.posargs:
263263
paths = session.posargs
264264
else:
@@ -282,7 +282,7 @@ def lint_tests(session):
282282
@nox.session(python="3")
283283
def docs(session):
284284
"""
285-
Build Docs
285+
Build Docs.
286286
"""
287287
session.install(
288288
"--progress-bar=off",
@@ -297,7 +297,7 @@ def docs(session):
297297
session.run("make", "coverage", "SPHINXOPTS=-W", external=True)
298298
docs_coverage_file = os.path.join("_build", "html", "python.txt")
299299
if os.path.exists(docs_coverage_file):
300-
with open(docs_coverage_file) as rfh:
300+
with open(docs_coverage_file, encoding="utf-8") as rfh:
301301
contents = rfh.readlines()[2:]
302302
if contents:
303303
session.error("\n" + "".join(contents))
@@ -308,7 +308,7 @@ def docs(session):
308308
@nox.session(name="docs-dev", python="3")
309309
def docs_dev(session):
310310
"""
311-
Build Docs
311+
Build Docs.
312312
"""
313313
session.install(
314314
"--progress-bar=off",
@@ -325,7 +325,7 @@ def docs_dev(session):
325325
@nox.session(name="docs-crosslink-info", python="3")
326326
def docs_crosslink_info(session):
327327
"""
328-
Report intersphinx cross links information
328+
Report intersphinx cross links information.
329329
"""
330330
session.install(
331331
"--progress-bar=off",
@@ -367,7 +367,7 @@ def docs_crosslink_info(session):
367367
@nox.session(name="gen-api-docs", python="3")
368368
def gen_api_docs(session):
369369
"""
370-
Generate API Docs
370+
Generate API Docs.
371371
"""
372372
session.install(
373373
"--progress-bar=off",

requirements/lint.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
-r base.txt
22
-r tests.txt
3-
pylint==2.7.4
4-
saltpylint==2020.9.28
3+
pylint==2.12.2
54
pyenchant
65
black; python_version >= '3.7'
76
reorder-python-imports; python_version >= '3.7'
7+
flake8 >= 4.0.1
8+
flake8-mypy-fork
9+
flake8-docstrings
10+
flake8-typing-imports

0 commit comments

Comments
 (0)