Kaydet (Commit) 3847336f authored tarafından Batuhan Osman TASKAYA's avatar Batuhan Osman TASKAYA

format code

üst 4d666264
...@@ -22,7 +22,7 @@ pipeline { ...@@ -22,7 +22,7 @@ pipeline {
stage('flake8') { stage('flake8') {
steps { steps {
sh """. .venv/bin/activate sh """. .venv/bin/activate
flake8 --max-complexity 7 --output-file flake8_results.txt --ignore E501,F402 darwcss/ flake8 --max-complexity 7 --output-file flake8_results.txt --ignore E501,F402,W291,E202 darwcss/
[ -f flake8_results.txt ] && flake8_junit flake8_results.txt test_flake8.xml;rm flake8_results.txt [ -f flake8_results.txt ] && flake8_junit flake8_results.txt test_flake8.xml;rm flake8_results.txt
""" """
} }
......
from __future__ import annotations from __future__ import annotations
from contextlib import contextmanager from contextlib import contextmanager
from typing import List, Any, Union, Optional, Generator, Dict, Tuple, Sequence, Callable from typing import (
List,
Any,
Union,
Optional,
Generator,
Dict,
Tuple,
Sequence,
Callable,
)
from inspect import currentframe from inspect import currentframe
from textwrap import indent from textwrap import indent
from colorsys import rgb_to_hls from colorsys import rgb_to_hls
...@@ -18,7 +28,13 @@ noqa:F821 = https://github.com/PyCQA/pyflakes/issues/373 ...@@ -18,7 +28,13 @@ noqa:F821 = https://github.com/PyCQA/pyflakes/issues/373
class ArgumentMapping(UserDict): class ArgumentMapping(UserDict):
@classmethod @classmethod
def fill_rest(cls, keys: Sequence, values: Sequence, filler: Callable[[Any], Any] = None, cleaner: Callable[[Any], Any ] = None) -> Dict[Any, Any]: def fill_rest(
cls,
keys: Sequence,
values: Sequence,
filler: Callable[[Any], Any] = None,
cleaner: Callable[[Any], Any] = None,
) -> Dict[Any, Any]:
cleaner = cleaner or (lambda value: value) cleaner = cleaner or (lambda value: value)
if len(keys) != len(values): if len(keys) != len(values):
requested_keys = keys[len(keys) - len(values):] requested_keys = keys[len(keys) - len(values):]
...@@ -38,13 +54,13 @@ class ArgumentMapping(UserDict): ...@@ -38,13 +54,13 @@ class ArgumentMapping(UserDict):
def value_generator(fields: Sequence[Field]) -> List[Any]: def value_generator(fields: Sequence[Field]) -> List[Any]:
values: List[Any] = [] values: List[Any] = []
for field in fields: for field in fields:
if field.default_factory is MISSING: # type: ignore if field.default_factory is MISSING: # type: ignore
if field.default is MISSING: if field.default is MISSING:
values.append(None) values.append(None)
else: else:
values.append(field.default) values.append(field.default)
else: else:
values.append(field.default_factory()) # type: ignore values.append(field.default_factory()) # type: ignore
return values return values
...@@ -76,11 +92,14 @@ def init(*values, **kwds) -> None: ...@@ -76,11 +92,14 @@ def init(*values, **kwds) -> None:
def fake_init(cls: type, fields: Sequence[Field]) -> object: def fake_init(cls: type, fields: Sequence[Field]) -> object:
return cls(**dict(zip(map(attrgetter("name"), fields), value_generator(fields)))) # type: ignore return cls(
**dict(zip(map(attrgetter("name"), fields), value_generator(fields))) # type: ignore
)
def configurable_dataclass(*args, **kwargs) -> type: def configurable_dataclass(*args, **kwargs) -> type:
cls = dataclass(*args, **kwargs) cls = dataclass(*args, **kwargs)
meta_conf: Field = field(default_factory=dict) # type: ignore meta_conf: Field = field(default_factory=dict) # type: ignore
meta_conf.name = "meta_cfg" meta_conf.name = "meta_cfg"
cls_fields = fields(cls) cls_fields = fields(cls)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment