Skip to content

Commit

Permalink
Switch over to Ruff completely, modernize CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Iapetus-11 committed Jan 15, 2025
1 parent 4746487 commit e141924
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 193 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Run Checks

on: [ push, pull_request, workflow_dispatch ]

jobs:
checks:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4

- name: Set up python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
run: curl -sSL https://install.python-poetry.org | python3 -

- name: Configure Poetry
run: poetry config virtualenvs.in-project true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
run: poetry install

- name: Run Ruff linter
run: poetry run ruff check . --no-fix

- name: Run Ruff formatter
run: poetry run ruff format . --check
39 changes: 0 additions & 39 deletions .github/workflows/ci.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ MANIFEST.in
dist/
.venv/
.idea/
.ruff_cache/
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# To-Ascii ![Code Quality](https://www.codefactor.io/repository/github/iapetus-11/to-ascii/badge/master) ![PYPI Version](https://img.shields.io/pypi/v/to-ascii.svg) ![PYPI Downloads](https://img.shields.io/pypi/dw/to-ascii?color=0FAE6E)
# To-ASCII ![Code Quality](https://www.codefactor.io/repository/github/iapetus-11/to-ascii/badge/master) ![PYPI Version](https://img.shields.io/pypi/v/to-ascii.svg) ![PYPI Downloads](https://img.shields.io/pypi/dw/to-ascii?color=0FAE6E)
*Converts videos, images, gifs, and even live video into ascii art!*

* Works on most image and video types including GIFs
* Works on LIVE VIDEO
- Works on most image and video types including GIFs
- Works on LIVE VIDEO

<img src="https://user-images.githubusercontent.com/38477514/180253533-e0725ba5-6c6d-408d-a643-ff02f021cff8.png" width="360" /> <img src="https://user-images.githubusercontent.com/38477514/180254306-9e8eca93-ea38-47bf-b1c2-72ad75244604.png" width="360" /> <img src="https://user-images.githubusercontent.com/38477514/180251469-8826a23d-a292-42b2-83c6-c9a637214b5e.png" width="360" /> <img src="https://user-images.githubusercontent.com/38477514/180251666-49b07f5f-da3c-4790-85b9-ba72dbca606b.png" width="360" />

Expand Down
152 changes: 21 additions & 131 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

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

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
1 change: 1 addition & 0 deletions toascii/converters/color_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
COLOR_TRUNC = 128
COLOR_TRUNC_TO = 256 // COLOR_TRUNC


# generates all colors possible within the color space COLOR_TRUNC_TO
def _gen_colors() -> Generator[T_COLOR, None, None]:
for r in range(0, COLOR_TRUNC_TO):
Expand Down
2 changes: 1 addition & 1 deletion toascii/converters/html_color_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def _asciify_image(self, image: np.ndarray) -> Generator[str, None, None]:
yield "</span>"

last_color = color
yield f"""<span style="color:rgb({','.join(map(str, color))})">"""
yield f"""<span style="color:rgb({",".join(map(str, color))})">"""

yield char

Expand Down
26 changes: 10 additions & 16 deletions toascii/media_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,43 +47,37 @@ def ensure_valid(self) -> None:

@property
@abc.abstractmethod
def is_live(self) -> bool:
...
def is_live(self) -> bool: ...

@property
@abc.abstractmethod
def fps(self) -> float:
...
def fps(self) -> float: ...

@property
@abc.abstractmethod
def width(self) -> int:
...
def width(self) -> int: ...

@property
@abc.abstractmethod
def height(self) -> int:
...
def height(self) -> int: ...

@property
@abc.abstractmethod
def frame_count(self) -> int:
...
def frame_count(self) -> int: ...

def __iter__(self) -> typing_extensions.Self:
return self

@abc.abstractmethod
def __next__(self) -> numpy.ndarray:
...
def __next__(self) -> numpy.ndarray: ...

@abc.abstractmethod
def __enter__(self) -> typing_extensions.Self:
...
def __enter__(self) -> typing_extensions.Self: ...

@abc.abstractmethod
def __exit__(self, exc_type: Type[BaseException], exc_val: BaseException, exc_tb: Any) -> None:
...
def __exit__(
self, exc_type: Type[BaseException], exc_val: BaseException, exc_tb: Any
) -> None: ...


class OpenCVVideoSource(AbstractVideoSource):
Expand Down

0 comments on commit e141924

Please sign in to comment.