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

Upgrade from autoflake to ruff + misc linter fixes + update CI workflow #5

Merged
merged 2 commits into from
Nov 6, 2023
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
27 changes: 9 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
name: CI

on:
push:
pull_request:
types: [opened]
on: [ push, pull_request, workflow_dispatch ]

jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: set up python 3.8
- name: set up python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.8"
python-version: "3.10"

- name: install poetry
run: curl -sSL https://install.python-poetry.org | python3 -
Expand All @@ -30,19 +27,13 @@ jobs:
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}

- name: install dependencies
# if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install

- name: auto-flake
run: poetry run autoflake --remove-all-unused-imports --expand-star-imports --ignore-init-module-imports --in-place --recursive toascii/
- name: black check
run: poetry run black . --check

- name: black fix
run: poetry run black .
- name: isort check
run: poetry run isort . --check

- name: isort fix
run: poetry run isort .

- name: auto commit
uses: stefanzweifel/git-auto-commit-action@v4.14.1
with:
commit_message: format / fix code
- name: ruff
run: poetry run ruff . --no-fix
311 changes: 148 additions & 163 deletions poetry.lock

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ cli = ["click"]
toascii = "toascii.cli:toascii_command"

[tool.poetry.group.dev.dependencies]
autoflake = "^1.6.1"
isort = "^5.10.1"
black = "^22.8.0"
ruff = "^0.1.4"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand All @@ -44,3 +44,8 @@ include = '\.pyi?$'
[tool.isort]
profile = "black"
line_length = 100

[tool.ruff]
line-length = 100
#ignore = ["E501", "E266", "E203", "E741", "W293", "W291"]
target-version = "py38"
8 changes: 5 additions & 3 deletions toascii/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import pkg_resources
# ruff: noqa: F401

import importlib.metadata

from . import gradients
from .converters import *
from .converters import * # noqa: F403
from .image import Image
from .video import FrameClearStrategy, Video

__version__ = pkg_resources.get_distribution("to-ascii").version
__version__ = importlib.metadata.version("to-ascii")
11 changes: 11 additions & 0 deletions toascii/converters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,14 @@
HtmlColorConverterNim = unsupported_extension(
"html_color_converter_nim.HtmlColorConverterNim", e
)

__all__ = (
"BaseConverter",
"ColorConverter",
"GrayscaleConverter",
"HtmlColorConverter",
"ConverterOptions",
"ColorConverterNim",
"GrayscaleConverterNim",
"HtmlColorConverterNim",
)
1 change: 1 addition & 0 deletions toascii/converters/color_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def _trunc_color(r: int, g: int, b: int) -> Tuple[int, int, int]:
}


# ruff: noqa: E741
def _rgb2hsl(c: T_COLOR) -> T_HSL_COLOR:
r = c[0] / 255.0
g = c[1] / 255.0
Expand Down
4 changes: 2 additions & 2 deletions toascii/converters/extensions/color_converter_nim.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import numpy as np

from ..color_converter import RGB_TO_ASCII_CODE, ColorConverter
from .extension_utils import build_extensions

build_extensions()

from ..color_converter import RGB_TO_ASCII_CODE, ColorConverter
from . import color_converter
from . import color_converter # noqa

color_converter.setRgbValuesMap(list(RGB_TO_ASCII_CODE.items()))

Expand Down
4 changes: 2 additions & 2 deletions toascii/converters/extensions/grayscale_converter_nim.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import numpy as np

from ..grayscale_converter import GrayscaleConverter
from .extension_utils import build_extensions

build_extensions()

from ..grayscale_converter import GrayscaleConverter
from . import grayscale_converter
from . import grayscale_converter # noqa


class GrayscaleConverterNim(GrayscaleConverter):
Expand Down
4 changes: 2 additions & 2 deletions toascii/converters/extensions/html_color_converter_nim.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import numpy as np

from ..html_color_converter import HtmlColorConverter
from .extension_utils import build_extensions

build_extensions()

from ..html_color_converter import HtmlColorConverter
from . import html_color_converter
from . import html_color_converter # noqa


class HtmlColorConverterNim(HtmlColorConverter):
Expand Down
2 changes: 1 addition & 1 deletion toascii/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def _get_print_affixes(self, video: AbstractVideoSource) -> Tuple[str, str]:
elif self.frame_clear_strategy is FrameClearStrategy.ANSI_ERASE_IN_DISPLAY:
print_prefix = "\033[2J"
elif self.frame_clear_strategy is FrameClearStrategy.ANSI_CURSOR_POS:
print_prefix = f"\033[H"
print_prefix = "\033[H"

return print_prefix, print_suffix

Expand Down
Loading