Skip to content

Commit 3ed8464

Browse files
author
Sylvain MARIE
committed
Flake8 once again.
1 parent 7326ec0 commit 3ed8464

File tree

5 files changed

+38
-37
lines changed

5 files changed

+38
-37
lines changed

pyfields/autofields_.py

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -258,28 +258,28 @@ def is_reserved_dunder(name):
258258

259259

260260
def autoclass(
261-
# --- autofields
262-
fields=True, # type: Union[bool, DecoratedClass]
263-
typecheck=False, # type: bool
264-
# --- constructor
265-
init=True, # type: bool
266-
# --- class methods
267-
dict=True, # type: bool
268-
dict_public_only=True, # type: bool
269-
repr=True, # type: bool
270-
repr_curly_mode=False, # type: bool
271-
repr_public_only=True, # type: bool
272-
eq=True, # type: bool
273-
eq_public_only=False, # type: bool
274-
hash=True, # type: bool
275-
hash_public_only=False, # type: bool
276-
# --- advanced
277-
af_include_upper=False, # type: bool
278-
af_include_dunder=False, # type: bool
279-
af_exclude=DEFAULT_EXCLUDED, # type: Iterable[str]
280-
ac_include=None, # type: Union[str, Tuple[str]]
281-
ac_exclude=None, # type: Union[str, Tuple[str]]
282-
):
261+
# --- autofields
262+
fields=True, # type: Union[bool, DecoratedClass]
263+
typecheck=False, # type: bool
264+
# --- constructor
265+
init=True, # type: bool
266+
# --- class methods
267+
dict=True, # type: bool
268+
dict_public_only=True, # type: bool
269+
repr=True, # type: bool
270+
repr_curly_mode=False, # type: bool
271+
repr_public_only=True, # type: bool
272+
eq=True, # type: bool
273+
eq_public_only=False, # type: bool
274+
hash=True, # type: bool
275+
hash_public_only=False, # type: bool
276+
# --- advanced
277+
af_include_upper=False, # type: bool
278+
af_include_dunder=False, # type: bool
279+
af_exclude=DEFAULT_EXCLUDED, # type: Iterable[str]
280+
ac_include=None, # type: Union[str, Tuple[str]]
281+
ac_exclude=None, # type: Union[str, Tuple[str]]
282+
):
283283
"""
284284
A decorator to automate many things at once for your class.
285285
@@ -407,7 +407,7 @@ def from_dict(cls, dct):
407407
def __repr__(self):
408408
""" Generated by @pyfields.autoclass based on the class fields """
409409
return '%s(%s)' % (self.__class__.__name__,
410-
', '.join('%s=%r' % (k, getattr(self, k)) for k in repr_names))
410+
', '.join('%s=%r' % (k, getattr(self, k)) for k in repr_names))
411411
else:
412412
def __repr__(self):
413413
""" Generated by @pyfields.autoclass based on the class fields """
@@ -422,6 +422,7 @@ def __repr__(self):
422422
# __eq__
423423
if eq:
424424
eq_names = public_selected_names if eq_public_only else selected_names
425+
425426
def __eq__(self, other):
426427
""" Generated by @pyfields.autoclass based on the class fields """
427428
if isinstance(other, dict):
@@ -532,8 +533,8 @@ def filter_names(all_names,
532533
# ):
533534
# # type: (...) -> bool
534535
# """
535-
# Returns True if method `method_name` is already implemented by object_type, that is, its implementation differs from
536-
# the one in `object`.
536+
# Returns True if method `method_name` is already implemented by object_type, that is, its implementation differs
537+
# from the one in `object`.
537538
#
538539
# :param cls:
539540
# :param method_name:

pyfields/core.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
try:
1111
from inspect import signature, Parameter
12-
except ImportError:
12+
except ImportError: # noqa
1313
# noinspection PyUnresolvedReferences,PyPackageRequirements
1414
from funcsigs import signature, Parameter
1515

@@ -20,7 +20,7 @@
2020

2121
try: # python 3.5+
2222
# noinspection PyUnresolvedReferences
23-
from typing import List, Callable, Type, Any, Union, Iterable, Tuple, TypeVar
23+
from typing import Callable, Type, Any, Union, Iterable, Tuple, TypeVar
2424
_NoneType = type(None)
2525
use_type_hints = sys.version_info > (3, 0)
2626
if use_type_hints:
@@ -708,7 +708,7 @@ def field(type_hint=None, # type: Union[Type[T], Iterable[Type[T]]]
708708
709709
- @lazy_attribute (sagemath)
710710
- @cached_property (werkzeug) and https://stackoverflow.com/questions/24704147/python-what-is-a-lazy-property
711-
- https://stackoverflow.com/questions/42023852/how-can-i-get-the-attribute-name-when-working-with-descriptor-protocol-in-python
711+
- https://stackoverflow.com/q/42023852/7262247
712712
- attrs / dataclasses
713713
714714
:param type_hint: an optional explicit type hint for the field, to override the type hint defined by PEP484
@@ -718,8 +718,8 @@ def field(type_hint=None, # type: Union[Type[T], Iterable[Type[T]]]
718718
:param nonable: a boolean that can be used to explicitly declare that a field can contain `None`. When this is set
719719
to an explicit `True` or `False` value, usual type checking and validation (*if any*) are not anymore executed
720720
on `None` values. Instead ; if this is `True`, type checking and validation will be *deactivated* when the field
721-
is set to `None` so as to always accept the value. If this is `False`, an `None`error will be raised when `None` is
722-
set on the field.
721+
is set to `None` so as to always accept the value. If this is `False`, an `None`error will be raised when `None`
722+
is set on the field.
723723
When this is left as `GUESS` (default), the behaviour is "automatic". This means that
724724
- if the field (a) is optional with default value `None` or (b) has type hint `typing.Optional[]`, the
725725
behaviour will be the same as with `nonable=True`.
@@ -1082,15 +1082,15 @@ def __set__(self,
10821082
try:
10831083
# does the converter accept this input ?
10841084
accepted = converter.accepts(obj, self, value)
1085-
except Exception:
1085+
except Exception: # noqa
10861086
# ignore all exceptions from converters
10871087
continue
10881088
else:
10891089
if accepted is None or accepted:
10901090
# if so, let's try to convert
10911091
try:
10921092
converted_value = converter.convert(obj, self, value)
1093-
except Exception:
1093+
except Exception: # noqa
10941094
# ignore all exceptions from converters
10951095
continue
10961096
else:

pyfields/init_makers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313

1414

1515
try: # python 3.5+
16-
from typing import Optional, Set, List, Callable, Dict, Type, Any, TypeVar, Union, Iterable, Tuple, Mapping
17-
from valid8.common_syntax import ValidationFuncs
16+
from typing import List, Callable, Any, Union, Iterable, Tuple
1817
use_type_hints = sys.version_info > (3, 0)
1918
except ImportError:
2019
use_type_hints = False
@@ -330,7 +329,8 @@ def __get__(self, obj, objtype):
330329
user_init_fun=self.user_init_fun, user_init_args_before=self.user_init_args_before)
331330

332331
# replace it forever in the class
333-
setattr(objtype, '__init__', new_init)
332+
# setattr(objtype, '__init__', new_init)
333+
objtype.__init__ = new_init
334334

335335
# return the new init
336336
return new_init.__get__(obj, objtype)

pyfields/validate_n_convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
try: # python 3.5+
1717
# noinspection PyUnresolvedReferences
1818
from typing import Callable, Type, Any, TypeVar, Union, Iterable, Tuple, Mapping, Optional, Dict, Literal
19-
from valid8.common_syntax import ValidationFuncs
19+
# from valid8.common_syntax import ValidationFuncs
2020
use_type_hints = sys.version_info > (3, 0)
2121
except ImportError:
2222
use_type_hints = False

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ exclude_lines =
129129
max-line-length = 120
130130
extend-ignore = D, E203 # D: Docstring errors, E203: see https://github.com/PyCQA/pycodestyle/issues/373
131131
copyright-check = True
132-
copyright-regexp = ^\#\s+Authors:\s+Sylvain MARIE <sylvain\.marie@se\.com>\n\#\s+\+\sAll\scontributors\sto\s<https://github\.com/smarie/python\-makefun>\n\#\n\#\s+License:\s3\-clause\sBSD,\s<https://github\.com/smarie/python\-pyfields/blob/master/LICENSE>
132+
copyright-regexp = ^\#\s+Authors:\s+Sylvain MARIE <sylvain\.marie@se\.com>\n\#\s+\+\sAll\scontributors\sto\s<https://github\.com/smarie/python\-pyfields>\n\#\n\#\s+License:\s3\-clause\sBSD,\s<https://github\.com/smarie/python\-pyfields/blob/master/LICENSE>
133133
exclude =
134134
.git
135135
.github

0 commit comments

Comments
 (0)