Kaydet (Commit) 1227c318 authored tarafından Batuhan Osman TASKAYA's avatar Batuhan Osman TASKAYA

flake 8 integration

üst 7ac05275
......@@ -5,7 +5,7 @@ pipeline {
steps {
sh 'python -m venv .venv'
sh """. .venv/bin/activate
pip install pytest twine mypy
pip install pytest twine mypy flake8 mccabe lake8-junit-repor
pip install -e ."""
}
}
......@@ -16,10 +16,19 @@ pipeline {
"""
}
}
stage('flake8') {
steps {
sh """. .venv/bin/activate
flake8 --max-complexity 7 --output-file flake8_results.txt darwc
flake8_junit flake8_results.txt test_flake8.xml
rm flake8_results.txt
"""
}
}
stage('mypy') {
steps {
sh """. .venv/bin/activate
mypy --junit-xml=test_mpy.xml darwcss/
mypy --junit-xml=test_mypy.xml darwcss/
"""
}
}
......
from __future__ import annotations
from contextlib import contextmanager
from dataclasses import dataclass, field
from typing import List, Any, Union, Optional, Generator, Dict
from typing import List, Any, Union, Optional, Generator, Dict, Tuple
from inspect import currentframe
from textwrap import indent
from colorsys import rgb_to_hls, rgb_to_hsv, rgb_to_yiq
from colorsys import rgb_to_hls
from enum import Enum
def render(obj: Any) -> str:
......@@ -20,26 +21,41 @@ class RenderableObject:
def __render__(self) -> str:
pass
def __add__(self, other: RenderableObject) -> str:
def __add__(self, other: RenderableObject) -> str: # noqa:F821 https://github.com/PyCQA/pyflakes/issues/373
return f"{render(self)} {render(other)}"
def __radd__(self, other: RenderableObject) -> str:
def __radd__(self, other: RenderableObject) -> str: # noqa:F821
return f"{render(other)} {render(self)}"
class ColorTypes(Enum):
RGB = 0
HLS = 1
HEX = 2
@dataclass
class ColorValue(RenderableObject):
red: int
green: int
blue: int
typ: str = "rgb"
typ: ColorTypes = ColorTypes.RGB
def __render__(self) -> str:
return (
f"rgb({self.red}, {self.green}, {self.blue})"
if self.typ == "rgb"
else f"#{self.red}{self.green}{self.blue}"
)
if self.typ is ColorTypes.RGB:
return f"rgb({self.red}, {self.green}, {self.blue})"
elif self.typ is ColorTypes.HLS:
return f"hls({self.red}, {self.green}%, {self.blue}%)"
elif self.typ is ColorTypes.HEX:
return f"#{self.red}{self.green}{self.blue}"
else:
raise ValueError("ColorValue type must be a valid ColorTypes attribute")
def to_hls(self) -> Union[Tuple[float, float, float], NotImplemented]:
if self.typ is ColorTypes.RGB:
return rgb_to_hls(self.red, self.green, self.blue)
else:
return NotImplemented
@dataclass
......@@ -81,7 +97,7 @@ class Selector:
def __add__(self, other: Style) -> None:
self.styles.append(other)
def __iadd__(self, other: Style) -> Selector:
def __iadd__(self, other: Style) -> Selector: # noqa:F821
self + other
return self
......
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