Skip to content

Commit 3750459

Browse files
committed
initial pre-commit
1 parent 7a158fd commit 3750459

File tree

6 files changed

+67
-15
lines changed

6 files changed

+67
-15
lines changed

.pre-commit-config.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.0.1
4+
hooks:
5+
- id: check-yaml
6+
- id: end-of-file-fixer
7+
- id: trailing-whitespace
8+
- id: mixed-line-ending
9+
10+
- repo: https://github.com/pycqa/isort
11+
rev: 5.9.3
12+
hooks:
13+
- id: isort
14+
name: isort (python)
15+
- id: isort
16+
name: isort (cython)
17+
types: [cython]
18+
- id: isort
19+
name: isort (pyi)
20+
types: [pyi]
21+
22+
- repo: https://github.com/psf/black
23+
rev: 21.10b0
24+
hooks:
25+
- id: black
26+
# It is recommended to specify the latest version of Python
27+
# supported by your project here, or alternatively use
28+
# pre-commit's default_language_version, see
29+
# https://pre-commit.com/#top_level-default_language_version
30+
language_version: python3.7
31+
always_run: true
32+
33+
- repo: https://github.com/pre-commit/pygrep-hooks
34+
rev: v1.9.0 # Use the ref you want to point at
35+
hooks:
36+
- id: python-check-blanket-noqa
37+
- id: python-check-blanket-type-ignore
38+
- id: rst-directive-colons
39+
- id: rst-inline-touching-normal
40+
41+
- repo: https://gitlab.com/pycqa/flake8
42+
rev: 3.9.2
43+
hooks:
44+
- id: flake8
45+
additional_dependencies: [flake8-bugbear, pep8-naming, flake8-docstrings]
46+
exclude: test
47+
48+
- repo: https://github.com/pycqa/pylint
49+
rev: v2.11.1
50+
hooks:
51+
- id: pylint
52+
exclude: test

logwrap/log_wrap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ def wrapper(*args: typing.Any, **kwargs: typing.Any) -> typing.Any:
684684
raise
685685
return result
686686

687-
return async_wrapper if asyncio.iscoroutinefunction(func) else wrapper # type: ignore
687+
return async_wrapper if asyncio.iscoroutinefunction(func) else wrapper # type: ignore[return-value]
688688

689689
def __call__(self, func: _WrappedT) -> _WrappedT:
690690
"""Callable instance.

logwrap/repr_utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,11 @@ def _prepare_repr(func: typing.Union[types.FunctionType, types.MethodType]) -> t
158158
if not ismethod:
159159
real_func: typing.Callable[..., typing.Any] = func
160160
else:
161-
real_func = func.__func__ # type: ignore
161+
real_func = func.__func__ # type: ignore[union-attr]
162162

163163
for param in inspect.signature(real_func).parameters.values():
164-
if not self_processed and ismethod and func.__self__ is not None: # type: ignore
165-
result.append(ReprParameter(param, value=func.__self__)) # type: ignore
164+
if not self_processed and ismethod and func.__self__ is not None: # type: ignore[union-attr]
165+
result.append(ReprParameter(param, value=func.__self__)) # type: ignore[union-attr]
166166
self_processed = True
167167
else:
168168
result.append(ReprParameter(param))
@@ -374,7 +374,7 @@ def process_element(
374374
"""
375375
if hasattr(src, self._magic_method_name):
376376
result = getattr(src, self._magic_method_name)(self, indent=indent, no_indent_start=no_indent_start)
377-
return result # type: ignore
377+
return result # type: ignore[no-any-return]
378378

379379
if _known_callable(src):
380380
return self._repr_callable(src=src, indent=indent)

logwrap/repr_utils.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ cdef:
115115
if not ismethod:
116116
real_func = func
117117
else:
118-
real_func = func.__func__ # type: ignore
118+
real_func = func.__func__
119119

120120
for param in inspect.signature(real_func).parameters.values():
121121
if not self_processed and ismethod and func.__self__ is not None:
@@ -313,7 +313,7 @@ cdef class PrettyFormat:
313313

314314
if hasattr(src, self._magic_method_name):
315315
result = getattr(src, self._magic_method_name)(self, indent=indent, no_indent_start=no_indent_start)
316-
return result # type: ignore
316+
return result
317317

318318
if _known_callable(src):
319319
return self._repr_callable(src=src, indent=indent)

test/test_log_wrap_py3.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
1414

15-
# pylint: disable=missing-docstring, unused-argument
15+
# pylint: disable=unused-argument
1616

17-
"""Python 3 specific tests"""
17+
"""Python 3 specific tests."""
1818

1919
from __future__ import annotations
2020

2121
# Standard Library
2222
import asyncio
2323
import io
2424
import logging
25-
import typing # noqa # pylint: disable=unused-import
25+
import typing
2626
import unittest
2727
from unittest import mock
2828

@@ -150,15 +150,15 @@ def tearDown(self):
150150

151151
def test_01_annotation_args(self):
152152
@logwrap.logwrap
153-
def func(a: typing.Optional[int] = None):
153+
def func(arg: typing.Optional[int] = None):
154154
pass
155155

156156
func()
157157
self.assertEqual(
158158
"DEBUG>Calling: \n"
159159
"func(\n"
160160
" # POSITIONAL_OR_KEYWORD:\n"
161-
" a=None, # type: typing.Optional[int]\n"
161+
" arg=None, # type: typing.Optional[int]\n"
162162
")\n"
163163
"DEBUG>Done: 'func' with result:\n"
164164
"None\n",
@@ -167,15 +167,15 @@ def func(a: typing.Optional[int] = None):
167167

168168
def test_02_annotation_args(self):
169169
@logwrap.logwrap
170-
def func(a: int = 0):
170+
def func(arg: int = 0):
171171
pass
172172

173173
func()
174174
self.assertEqual(
175175
"DEBUG>Calling: \n"
176176
"func(\n"
177177
" # POSITIONAL_OR_KEYWORD:\n"
178-
" a=0, # type: int\n"
178+
" arg=0, # type: int\n"
179179
")\n"
180180
"DEBUG>Done: 'func' with result:\n"
181181
"None\n",

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ deps =
101101
-r{toxinidir}/CI_REQUIREMENTS.txt
102102
commands =
103103
python setup.py --version clean
104-
mypy --strict --xslt-html-report mypy_report -p logwrap
104+
mypy --strict --show-error-codes --xslt-html-report mypy_report -p logwrap
105105

106106
[testenv:isort]
107107
deps =

0 commit comments

Comments
 (0)