Skip to content

Commit

Permalink
Merge pull request #62 from sbrunner/prospector
Browse files Browse the repository at this point in the history
Add Prospector check
  • Loading branch information
sbrunner committed Aug 9, 2021
2 parents 74d5692 + 41f7085 commit 57dc665
Show file tree
Hide file tree
Showing 7 changed files with 398 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
- name: Checks
run: c2cciutils-checks

- run: pipenv sync --dev
- run: pipenv run prospector --output=pylint bashcolor

- name: Init pypi
run: |
echo "[pypi]" > ~/.pypirc
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pipfile.lock
22 changes: 22 additions & 0 deletions .prospector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
strictness: veryhigh

max-line-length: 110

pylint:
disable:
- too-many-arguments

pep8:
disable:
- E203 # Whitespace before ':'
- E722 # Do not use bare 'except'

bandit:
run: true

mypy:
run: true

mccabe:
run: false
11 changes: 11 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[dev-packages]
prospector = {version = "==1.3.1", extras = ["with_bandit", "with_mypy"]}
flake8 = "==3.8.4"

[requires]
python_version = "3.8"
335 changes: 335 additions & 0 deletions Pipfile.lock

Large diffs are not rendered by default.

32 changes: 20 additions & 12 deletions bashcolor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# see also: http://misc.flogisoft.com/bash/tip_colors_and_formatting


from typing import List, Optional

RESET = 0
BLACK = 30
RED = 31
Expand Down Expand Up @@ -35,8 +37,14 @@


def colorize(
text, color=None, background=None, effects=None, color_256=None, background_256=None, with_end=True
):
text: str,
color: Optional[int] = None,
background: Optional[int] = None,
effects: Optional[List[int]] = None,
color_256: Optional[int] = None,
background_256: Optional[int] = None,
with_end: bool = True,
) -> str:
if effects is None:
effects = []
start = []
Expand All @@ -60,25 +68,25 @@ def colorize(
start.append(effect)
end.append(effect + _RESET_EFFECT)

start_code = f"{_ESC!s}[{';'.join([str(s) for s in start])!s}m" if text != "" else ""
end_code = f"{_ESC!s}[{';'.join([str(e) for e in end])!s}m" if with_end else ""
return f"{start_code!s}{text!s}{end_code!s}"
start_code = f"{_ESC}[{';'.join([str(s) for s in start])}m" if text != "" else ""
end_code = f"{_ESC}[{';'.join([str(e) for e in end])}m" if with_end else ""
return f"{start_code}{text}{end_code}"


def print_colors():
def print_colors() -> None:
color_pivot = [0]
color_pivot += [e * 6 + 16 for e in range(37)]
color_pivot.append(256)
color_pivot_start = color_pivot[:-1]
color_pivot_end = color_pivot[1:]
color_table = [range(cs, ce) for cs, ce in zip(color_pivot_start, color_pivot_end)]
color_table_list = [range(cs, ce) for cs, ce in zip(color_pivot_start, color_pivot_end)]

for ct in color_table:
for color_table in color_table_list:
text = ""
for c in ct:
cs = str(c)
padding = "".join([" " for e in range(3 - len(cs))])
text += colorize(f" {padding!s}{cs!s} ", background_256=c, with_end=False)
for color in color_table:
color_string = str(color)
padding = "".join([" " for e in range(3 - len(color_string))])
text += colorize(f" {padding}{color_string} ", background_256=color, with_end=False)
print(text + colorize("", background=DEFAULT))


Expand Down
6 changes: 6 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[mypy]
python_version = 3.8
warn_redundant_casts = True
warn_unused_ignores = True
ignore_missing_imports = True
strict = True

0 comments on commit 57dc665

Please sign in to comment.