Skip to content

Commit f4e2dc4

Browse files
Fix lint
1 parent c15bd3e commit f4e2dc4

File tree

4 files changed

+35
-14
lines changed

4 files changed

+35
-14
lines changed

.pydocstyle

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[pydocstyle]
2+
# These are preferences:
3+
# D102 = Missing docstring in public method
4+
# D103 = Missing docstring in public function
5+
# D105 = Missing docstring in magic method
6+
# D107 = Missing docstring in __init__
7+
# These conflict with the Google style:
8+
# D202 = No blank lines allowed after function docstring
9+
# D203 = 1 blank line required before class docstring
10+
# D213 = Multi-line docstring summary should start at the second line
11+
# D413 = Missing blank line after last section
12+
ignore = D102,D103,D105,D107,D202,D203,D213,D413

README.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,9 @@ site, so that path to instance discovery is impossible; the type variable
140140

141141
.. code-block:: python
142142
143-
@typeclass('T')
144-
def to_json(value: 'T') -> str:
143+
T = typing.TypeVar('T')
144+
@typeclass(T)
145+
def to_json(value: T) -> str:
145146
"""Serialize a value to JSON."""
146147
147148
We may optionally provide a default implementation. If we do not, the

tests/test_tutorial.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1+
"""Test the tutorial from the documentation."""
2+
3+
# pylint: disable=invalid-name
4+
15
from dataclasses import dataclass
26
import typing
37

4-
import pytest
8+
import pytest # type: ignore
59

610
from typeclasses import typeclass
711

12+
T = typing.TypeVar('T')
13+
814

9-
@typeclass('T')
10-
def to_json(value: 'T') -> str:
15+
@typeclass(T)
16+
def to_json(value: T) -> str: # pylint: disable=unused-argument
1117
"""Serialize a value to JSON."""
1218

1319

typeclasses/decorator.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""The :func:`typeclass` decorator."""
2+
13
import functools
24
import inspect
35

@@ -7,11 +9,7 @@ def _empty():
79

810

911
def _docstring():
10-
"""A docstring."""
11-
12-
13-
def _return_type() -> None:
14-
pass
12+
"""Just an empty function with a docstring."""
1513

1614

1715
def _code(f):
@@ -25,17 +23,21 @@ def _code(f):
2523

2624
def _is_empty(f):
2725
"""Return whether a function has an empty body."""
28-
return _code(f) in (_code(_empty), _code(_docstring), _code(_return_type))
26+
return _code(f) in (_code(_empty), _code(_docstring))
2927

3028

3129
class TypeClassMethod:
32-
"""A type class of a single method.
30+
"""A method of a type class.
3331
34-
This docstring will be overwritten by that of the default implementation.
32+
This docstring will be overwritten by that of the method's default
33+
implementation.
3534
"""
3635

36+
__name__: str
37+
3738
def __init__(self, get_type_argument, default_implementation):
38-
"""
39+
"""Construct a type class method.
40+
3941
Parameters
4042
----------
4143
get_type_argument :

0 commit comments

Comments
 (0)