This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Correct decorator for an optional parameter | |
def print_before4(label='label'): | |
def decorator(func): | |
@functools.wraps(func) | |
def wrapped(*args, **kwargs): | |
print(label, args, kwargs) | |
return func(*args, **kwargs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dek | |
@dek | |
def print_before(pfunc, label='label'): | |
print(label, pfunc) | |
return pfunc() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dek = _dek(_dek, defer=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def loops_forever(function, *arguments): | |
# Return True if function(*arguments) loops forever | |
# Let's try it out | |
def loops_forever(): | |
while True: | |
print() | |
def loops_once(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def turing(function): | |
if not has_infinite_loop(function, function): | |
while True: | |
pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dataclasses import dataclass, field | |
@dataclass(order=True) | |
class Action: | |
name: str = 'test' | |
_name: str = field(default="undefined", init=False, compare=True, repr=False) | |
@property | |
def name(self) -> str: # pylint: disable=function-redefined |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dataclasses import dataclass | |
@dataclass | |
class B: | |
b: List[object] | |
@dataclass | |
class A: | |
a: B |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type AutoGenerated struct { | |
A struct { | |
B []interface{} `json:"b"` | |
} `json:"a"` | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from . import command | |
from engora import CONFIG | |
from pathlib import Path | |
from typer import Argument, Option | |
from typing import List, Optional | |
_CFGS = ( | |
'max_items', | |
'max_requests', | |
'only', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This has been replaced by the PyPi module https://pypi.org/project/dtyper/ | |
from argparse import Namespace | |
import dataclasses | |
import functools | |
import inspect | |
@functools.wraps(dataclasses.make_dataclass) | |
def dcommand(typer_f, **kwargs): |