| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
from datetime import datetime |
| 4 |
from typing import Any # NoQA: TC003 |
| 5 |
|
| 6 |
CONSTANT = 'foo' |
| 7 |
SENTINEL = object() |
| 8 |
|
| 9 |
|
| 10 |
def foo( |
| 11 |
name: str = CONSTANT, |
| 12 |
sentinel: Any = SENTINEL, |
| 13 |
now: datetime = datetime.now(), # NoQA: B008,DTZ005 |
| 14 |
color: int = 0xFFFFFF, |
| 15 |
*, |
| 16 |
kwarg1, |
| 17 |
kwarg2=0xFFFFFF, |
| 18 |
) -> None: |
| 19 |
"""docstring""" |
| 20 |
|
| 21 |
|
| 22 |
class Class: |
| 23 |
"""docstring""" |
| 24 |
|
| 25 |
def meth( |
| 26 |
self, |
| 27 |
name: str = CONSTANT, |
| 28 |
sentinel: Any = SENTINEL, |
| 29 |
now: datetime = datetime.now(), # NoQA: B008,DTZ005 |
| 30 |
color: int = 0xFFFFFF, |
| 31 |
*, |
| 32 |
kwarg1, |
| 33 |
kwarg2=0xFFFFFF, |
| 34 |
) -> None: |
| 35 |
"""docstring""" |
| 36 |
|
| 37 |
@classmethod |
| 38 |
def clsmeth( |
| 39 |
cls, |
| 40 |
name: str = CONSTANT, |
| 41 |
sentinel: Any = SENTINEL, |
| 42 |
now: datetime = datetime.now(), # NoQA: B008,DTZ005 |
| 43 |
color: int = 0xFFFFFF, |
| 44 |
*, |
| 45 |
kwarg1, |
| 46 |
kwarg2=0xFFFFFF, |
| 47 |
) -> None: |
| 48 |
"""docstring""" |
| 49 |
|
| 50 |
|
| 51 |
get_sentinel = lambda custom=SENTINEL: custom # NoQA: E731 |
| 52 |
"""docstring""" |
| 53 |
|
| 54 |
|
| 55 |
class MultiLine: |
| 56 |
"""docstring""" |
| 57 |
|
| 58 |
# The properties will raise a silent SyntaxError because "lambda self: 1" |
| 59 |
# will be detected as a function to update the default values of. However, |
| 60 |
# only prop3 will not fail because it's on a single line whereas the others |
| 61 |
# will fail to parse. |
| 62 |
|
| 63 |
# fmt: off |
| 64 |
prop1 = property( |
| 65 |
lambda self: 1, doc='docstring') |
| 66 |
|
| 67 |
prop2 = property( |
| 68 |
lambda self: 2, doc='docstring' |
| 69 |
) |
| 70 |
|
| 71 |
prop3 = property(lambda self: 3, doc='docstring') |
| 72 |
|
| 73 |
prop4 = (property |
| 74 |
(lambda self: 4, doc='docstring')) |
| 75 |
|
| 76 |
prop5 = property\ |
| 77 |
(lambda self: 5, doc='docstring') # NoQA: E211 |
| 78 |
# fmt: on |