Skip to content

Commit

Permalink
dev/ruff (#1531)
Browse files Browse the repository at this point in the history
* Install Ruff and uninstall Black, isort, and Flake8

* Run ruff format

* Update the format make rule

* Update the CI steps

* Fix
  • Loading branch information
whitphx authored Mar 5, 2024
1 parent 06626a2 commit 4944ad3
Show file tree
Hide file tree
Showing 14 changed files with 61 additions and 183 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,10 @@ jobs:
STREAMLIT_VERSION: ${{ matrix.streamlit-version }}
- name: Install dependencies
run: poetry install
- name: Lint with black, isort, and flake8
- name: Run Ruff
run: |
poetry run black . --check
poetry run isort . --check --resolve-all-configs
poetry run flake8
poetry run ruff check --output-format=github .
poetry run ruff format . --check
- name: Type checking with mypy
run: |
poetry run mypy .
Expand Down
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ pkg/build:
poetry build

format:
poetry run isort . --resolve-all-configs
poetry run black .
poetry run flake8
poetry run ruff format .
poetry run ruff check . --fix

docker/build:
# Set `--platform linux/amd64` because some packages do not work with Docker on M1 mac for now.
Expand Down
2 changes: 1 addition & 1 deletion app_deepspeech.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def download_file(url, download_to: Path, expected_size=None):
with urllib.request.urlopen(url) as response:
length = int(response.info()["Content-Length"])
counter = 0.0
MEGABYTES = 2.0 ** 20.0
MEGABYTES = 2.0**20.0
while True:
data = response.read(8192)
if not data:
Expand Down
3 changes: 0 additions & 3 deletions pages/.isort.cfg

This file was deleted.

1 change: 1 addition & 0 deletions pages/8_media_files_streaming.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Media streamings"""

import logging
from pathlib import Path
from typing import Dict, Optional, cast
Expand Down
3 changes: 3 additions & 0 deletions pages/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

[tool.ruff.lint.isort]
known-third-party = ["streamlit_webrtc"]
161 changes: 35 additions & 126 deletions poetry.lock

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

31 changes: 3 additions & 28 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ typing_extensions = { version = ">=3.7.4,<5.0.0", python = "<3.8" }
packaging = ">=20.0"

[tool.poetry.group.dev.dependencies]
black = "^21.12b0"
click = ">=7.0,<8.0" # We must specify the click version because we install older versions of Streamlit in the CI process and their depending click version is different from the newer releases.
isort = "^5.10.1"
flake8 = "^5.0.4"
ruff = "^0.3.0"
mypy = "^1.0.0"
pydub = "^0.25.1"
matplotlib = "^3.5.1"
Expand All @@ -39,31 +37,8 @@ pandas = [
streamlit = "^1.13.0"
twilio = ">=8.1,<10.0"

[tool.black]
line-length = 88
target-version = ['py38']
exclude = '''
(
/(
\.eggs # exclude a few common directories in the
| \.git # root of the project
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
| streamlit_webrtc/frontend
)
'''

[tool.isort]
# https://pycqa.github.io/isort/docs/configuration/black_compatibility/
profile = "black"
[tool.ruff.lint]
extend-select = ["I"]

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
2 changes: 1 addition & 1 deletion sample_utils/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def download_file(url, download_to: Path, expected_size=None):
with urllib.request.urlopen(url) as response:
length = int(response.info()["Content-Length"])
counter = 0.0
MEGABYTES = 2.0 ** 20.0
MEGABYTES = 2.0**20.0
while True:
data = response.read(8192)
if not data:
Expand Down
3 changes: 1 addition & 2 deletions scripts/release_check.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
""" A script to check whether a variable `_RELEASE` is set as True.
"""
"""A script to check whether a variable `_RELEASE` is set as True."""

import argparse
import ast
Expand Down
3 changes: 1 addition & 2 deletions streamlit_webrtc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""streamlit-webrtc
"""
"""streamlit-webrtc"""

try:
import importlib.metadata as importlib_metadata
Expand Down
1 change: 1 addition & 0 deletions streamlit_webrtc/components_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
Script begins...
"""

from streamlit import session_state as _state
from streamlit.components.v1 import components as _components

Expand Down
Loading

0 comments on commit 4944ad3

Please sign in to comment.