Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: replace black, isort, pylint and flake8 with Ruff #248

Merged
merged 4 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions .flake8

This file was deleted.

3 changes: 1 addition & 2 deletions .github/workflows/lint_test_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ jobs:

- name: lint-code
run: |
make flake
make lint
make check-lint

- name: semgrep
run: |
Expand Down
26 changes: 10 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,21 @@ version := $(shell poetry version | awk '{ print $$2 }')
pypi_usr := $(shell grep username ~/.pypirc | awk -F"= " '{ print $$2 }')
pypi_pwd := $(shell grep password ~/.pypirc | awk -F"= " '{ print $$2 }')

.PHONY: flake
flake:
@poetry run flake8 --ignore=F821,E501,W503,E704 .

.PHONY: lint
lint: flake
@echo "$(OK_COLOR)==> Linting code ...$(NO_COLOR)"
@poetry run pylint $(name)/ ./tests -rn -f colorized
lint:
@poetry run ruff check --fix ./$(name) ./tests ./examples

.PHONY: isort
isort:
@poetry run isort --atomic --verbose ./$(name) ./tests ./examples
.PHONY: check-lint
check-lint:
@poetry run ruff check --diff ./$(name) ./tests ./examples

.PHONY: fmt
fmt: isort
@poetry run black ./$(name) ./tests ./examples
fmt:
@poetry run ruff format ./$(name) ./tests ./examples

.PHONY: check-fmt
check-fmt:
@poetry run isort --check ./$(name) ./tests ./examples
@poetry run black --check ./$(name) ./tests ./examples
@poetry run ruff format --check ./$(name) ./tests ./examples

.PHONY: spellcheck
spellcheck:
Expand All @@ -49,7 +43,7 @@ clean-pyc:
@find . -name '*~' -exec rm -f {} +

.PHONY: test
test: clean-pyc flake
test: clean-pyc
@echo "$(OK_COLOR)==> Runnings tests ...$(NO_COLOR)"
@poetry run py.test -n auto -v

Expand All @@ -69,7 +63,7 @@ build: rm-build
@poetry build

.PHONY: publish
publish: flake build
publish: build
@echo "$(OK_COLOR)==> Publishing...$(NO_COLOR)"
@poetry publish -u $(pypi_usr) -p $(pypi_pwd)

Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@

[![Coverage](https://codecov.io/gh/pavdmyt/yaspin/branch/master/graph/badge.svg)](https://codecov.io/gh/pavdmyt/yaspin)
[![pypi](https://img.shields.io/pypi/v/yaspin.svg)](https://pypi.org/project/yaspin/)
[![black-fmt](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)

[![Versions](https://img.shields.io/pypi/pyversions/yaspin.svg)](https://pypi.org/project/yaspin/)

[![Wheel](https://img.shields.io/pypi/wheel/yaspin.svg)](https://pypi.org/project/yaspin/)
[![Examples](https://img.shields.io/badge/learn%20by-examples-0077b3.svg)](https://github.com/pavdmyt/yaspin/tree/master/examples)

[![DownloadsTot](https://static.pepy.tech/badge/yaspin)](https://pepy.tech/project/yaspin)
[![DownloadsW](https://static.pepy.tech/badge/yaspin/week)](https://pepy.tech/project/yaspin)

Expand Down
2 changes: 1 addition & 1 deletion examples/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def all_highlights():
"on_grey",
)
for highlight in highlights:
text = "On {0} color".format(highlight.split("_")[1])
text = "On {} color".format(highlight.split("_")[1])
sp.on_color, sp.text = highlight, text
time.sleep(2)

Expand Down
12 changes: 6 additions & 6 deletions examples/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def any_spinner_you_like():
spinner = getattr(Spinners, name)

spaces_qty = max_len - len(name) - len(msg) - len(spinner.frames[0])
text = "{0}{1}{2}".format(name, " " * spaces_qty, msg)
text = "{}{}{}".format(name, " " * spaces_qty, msg)

with kbi_safe_yaspin(spinner, text=text, color="cyan"):
time.sleep(period)
Expand All @@ -61,7 +61,7 @@ def colors_simple(sleep=0.7):
with kbi_safe_yaspin(Spinners.dots12) as sp:
for color in COLORS:
spaces_qty = max_len - len(color) - len(msg)
text = "{0}{1}{2}".format(color, " " * spaces_qty, msg)
text = "{}{}{}".format(color, " " * spaces_qty, msg)

sp.color = color
sp.text = text
Expand All @@ -76,9 +76,9 @@ def color_highlights(sleep=0.5):
with kbi_safe_yaspin(Spinners.bouncingBall) as sp:
for highlight in HIGHLIGHTS:
highlight_name = " ".join(highlight.split("_")[1:])
name = "On {0} color".format(highlight_name)
name = f"On {highlight_name} color"
spaces_qty = max_len - len(name) - len(msg)
text = "{0}{1}{2}".format(name, " " * spaces_qty, msg)
text = "{}{}{}".format(name, " " * spaces_qty, msg)

sp.on_color = highlight
sp.text = text
Expand All @@ -102,7 +102,7 @@ def color_attributes(sleep=0.8):
with kbi_safe_yaspin(Spinners.bouncingBall) as sp:
for descr in descriptions:
spaces_qty = max_len - len(descr) - len(msg)
text = "{0}{1}{2}".format(descr, " " * spaces_qty, msg)
text = "{}{}{}".format(descr, " " * spaces_qty, msg)

attr, color, _ = descr.split()
sp.attrs, sp.color = [attr.lower()], color
Expand Down Expand Up @@ -143,7 +143,7 @@ def parse_attrs(description):
# the existing list of previous attributes.
for descr in descriptions:
spaces_qty = max_len - len(descr) - len(msg)
text = "{0}{1}{2}".format(descr, " " * spaces_qty, msg)
text = "{}{}{}".format(descr, " " * spaces_qty, msg)

with kbi_safe_yaspin(Spinners.pong, text=text) as sp:
# Apply all color attributes from description
Expand Down
3 changes: 2 additions & 1 deletion examples/dynamic_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
Evaluates text on every spinner frame.
"""

import time
from datetime import datetime

import time

from yaspin import yaspin


Expand Down
8 changes: 4 additions & 4 deletions examples/ellipsis.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
from yaspin import yaspin

LONG_TEXT = (
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer venenatis lectus quis tincidunt venenatis."
"Proin interdum neque eu lectus finibus malesuada. Nunc vel nisl quis tellus porta euismod. Aenean dignissim"
"tortor eu sapien gravida efficitur. Aliquam consectetur aliquam ex facilisis tincidunt. Nunc luctus arcu nec"
"justo gravida efficitur."
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer venenatis lectus quis tincidunt "
"venenatis. Proin interdum neque eu lectus finibus malesuada. Nunc vel nisl quis tellus porta euismod. "
"Aenean dignissim tortor eu sapien gravida efficitur. Aliquam consectetur aliquam ex facilisis "
"tincidunt. Nunc luctus arcu nec justo gravida efficitur."
)


Expand Down
8 changes: 5 additions & 3 deletions examples/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ def passing_additional_info_into_signal_handler():
heads = random.randint(0, 1) == 1
tails = not heads

def my_handler(signum, frame, spinner, context={"heads": heads, "tails": tails}):
def my_handler(signum, frame, spinner, context=None):
if context is None:
context = {"heads": heads, "tails": tails}
if context["heads"]:
spinner.text = "heads!"
spinner.ok("🌕")
Expand Down Expand Up @@ -96,7 +98,7 @@ def my_handler(signum, frame, spinner):

with yaspin(sigmap=sigmap, text="Handling SIGUSR1 and SIGTERM") as sp:
sp.write("Send signals using `kill` command")
sp.write("E.g. $ kill -USR1 {0}".format(os.getpid()))
sp.write(f"E.g. $ kill -USR1 {os.getpid()}")
time.sleep(60)
sp.write("No signal received")

Expand Down Expand Up @@ -131,7 +133,7 @@ def unpacker():
)
with swirl as sp:
for p in range(0, 101, 5):
sp.text = "{0}% Unpacking".format(p)
sp.text = f"{p}% Unpacking"
time.sleep(random.random())
sp.green.ok("✔")

Expand Down
Loading