Skip to content

Commit

Permalink
Replace Flake8 with Ruff (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Dec 9, 2023
2 parents 1e1de9f + c2317ba commit 6a8045b
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 76 deletions.
5 changes: 1 addition & 4 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

[report]
# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma:
pragma: no cover

exclude_also =
# Don't complain if non-runnable code isn't run:
if __name__ == .__main__.:
2 changes: 0 additions & 2 deletions .flake8

This file was deleted.

26 changes: 0 additions & 26 deletions .github/labels.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,3 @@
# Default GitHub labels
- color: d73a4a
description: "Something isn't working"
name: bug
- color: cfd3d7
description: "This issue or pull request already exists"
name: duplicate
- color: a2eeef
description: "New feature or request"
name: enhancement
- color: 7057ff
description: "Good for newcomers"
name: good first issue
- color: 008672
description: "Extra attention is needed"
name: help wanted
- color: e4e669
description: "This doesn't seem right"
name: invalid
- color: d876e3
description: "Further information is requested"
name: question
- color: ffffff
description: "This will not be worked on"
name: wontfix

# Keep a Changelog labels
# https://keepachangelog.com/en/1.0.0/
- color: 0e8a16
Expand Down
4 changes: 0 additions & 4 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
"groupName": "github-actions",
"matchManagers": ["github-actions"],
"separateMajorMinor": "false"
},
{
"groupName": "requirements.txt",
"matchPaths": ["requirements.txt"]
}
],
"schedule": ["on the first day of the month"]
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ jobs:
needs: build-package

permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write

steps:
Expand All @@ -63,7 +62,6 @@ jobs:
needs: build-package

permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write

steps:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Lint

on: [push, pull_request, workflow_dispatch]

env:
FORCE_COLOR: 1

permissions:
contents: read

Expand All @@ -11,7 +14,7 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- uses: pre-commit/action@v3.0.0
47 changes: 21 additions & 26 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,17 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.14.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.7
hooks:
- id: pyupgrade
args: [--py38-plus]
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.9.1
rev: 23.11.0
hooks:
- id: black

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies:
[flake8-2020, flake8-errmsg, flake8-implicit-str-concat, flake8-logging]

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-case-conflict
- id: check-executables-have-shebangs
Expand All @@ -38,17 +21,17 @@ repos:
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
exclude: ^em/emojis.json$
exclude: ^src/em_keyboard/emojis.json$
- id: trailing-whitespace

- repo: https://github.com/tox-dev/pyproject-fmt
rev: 1.2.0
rev: 1.5.3
hooks:
- id: pyproject-fmt
additional_dependencies: [tox]

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.14
rev: v0.15
hooks:
- id: validate-pyproject

Expand All @@ -57,5 +40,17 @@ repos:
hooks:
- id: tox-ini-fmt

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.3-1
hooks:
- id: prettier
args: [--prose-wrap=always, --print-width=88]
exclude: ^src/em_keyboard/emoji.*\.json$

- repo: meta
hooks:
- id: check-hooks-apply
- id: check-useless-excludes

ci:
autoupdate_schedule: quarterly
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
[![codecov](https://codecov.io/gh/hugovk/em-keyboard/branch/main/graph/badge.svg)](https://codecov.io/gh/hugovk/em-keyboard)
[![GitHub](https://img.shields.io/github/license/hugovk/em-keyboard.svg)](LICENSE)

**Emoji your friends and colleagues from the comfort of your own
terminal.**
**Emoji your friends and colleagues from the comfort of your own terminal.**

**em** is a nifty command-line utility for referencing emoji characters
by name. Provide the names of a few emoji, and those lucky chosen emojis
will be displayed in your terminal, then copied to your clipboard.
Automagically.
**em** is a nifty command-line utility for referencing emoji characters by name. Provide
the names of a few emoji, and those lucky chosen emojis will be displayed in your
terminal, then copied to your clipboard. Automagically.

Emoji can be also searched by both categories and aspects.

Expand Down
28 changes: 24 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,28 @@ version.source = "vcs"
[tool.hatch.version.raw-options]
local_scheme = "no-local-version"

[tool.isort]
profile = "black"
[tool.ruff]
select = [
"C4", # flake8-comprehensions
"E", # pycodestyle errors
"EM", # flake8-errmsg
"F", # pyflakes errors
"I", # isort
"ISC", # flake8-implicit-str-concat
"PGH", # pygrep-hooks
"RUF100", # unused noqa (yesqa)
"UP", # pyupgrade
"W", # pycodestyle warnings
"YTT", # flake8-2020
# "LOG", # TODO: enable flake8-logging when it's not in preview anymore
]
extend-ignore = [
"E203", # Whitespace before ':'
"E221", # Multiple spaces before operator
"E226", # Missing whitespace around arithmetic operator
"E241", # Multiple spaces after ','
]

[tool.pytest.ini_options]
addopts = "--color=yes"
[tool.ruff.isort]
known-first-party = ["em_keyboard"]
required-imports = ["from __future__ import annotations"]
2 changes: 2 additions & 0 deletions scripts/run_command.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import shlex
import subprocess

Expand Down
2 changes: 1 addition & 1 deletion src/em_keyboard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
automatically added to your clipboard.
- ✨ 🍰 ✨ (sparkles shortcake sparkles)
"""

from __future__ import annotations

import argparse
import importlib.metadata
Expand Down
2 changes: 2 additions & 0 deletions tests/test_em.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import argparse
import random
from unittest.mock import call, patch
Expand Down

0 comments on commit 6a8045b

Please sign in to comment.