From 003ed05f11fc445ae9365d5e6f3ccf108ef10271 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sat, 9 Dec 2023 15:04:01 +0200 Subject: [PATCH 1/3] Update config --- .coveragerc | 5 +---- .github/labels.yml | 26 -------------------------- .github/renovate.json | 4 ---- .github/workflows/deploy.yml | 2 -- .github/workflows/lint.yml | 5 ++++- 5 files changed, 5 insertions(+), 37 deletions(-) diff --git a/.coveragerc b/.coveragerc index 0ab42b3..0f12707 100644 --- a/.coveragerc +++ b/.coveragerc @@ -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__.: diff --git a/.github/labels.yml b/.github/labels.yml index 17eb9c6..b599886 100644 --- a/.github/labels.yml +++ b/.github/labels.yml @@ -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 diff --git a/.github/renovate.json b/.github/renovate.json index e996928..2d2f276 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -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"] diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index db62f40..05a0142 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -38,7 +38,6 @@ jobs: needs: build-package permissions: - # IMPORTANT: this permission is mandatory for trusted publishing id-token: write steps: @@ -63,7 +62,6 @@ jobs: needs: build-package permissions: - # IMPORTANT: this permission is mandatory for trusted publishing id-token: write steps: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4cf8d37..dae63b0 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,6 +2,9 @@ name: Lint on: [push, pull_request, workflow_dispatch] +env: + FORCE_COLOR: 1 + permissions: contents: read @@ -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 From 9e6cc108cb9cb16c565902cffde9aa462c527e99 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sat, 9 Dec 2023 15:13:13 +0200 Subject: [PATCH 2/3] Replace Flake8 with Ruff --- .flake8 | 2 -- .pre-commit-config.yaml | 40 +++++++++++++------------------------ pyproject.toml | 28 ++++++++++++++++++++++---- scripts/run_command.py | 2 ++ src/em_keyboard/__init__.py | 2 +- tests/test_em.py | 2 ++ 6 files changed, 43 insertions(+), 33 deletions(-) delete mode 100644 .flake8 diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 2bcd70e..0000000 --- a/.flake8 +++ /dev/null @@ -1,2 +0,0 @@ -[flake8] -max-line-length = 88 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 23b795f..6ad2236 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -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 @@ -57,5 +40,10 @@ repos: hooks: - id: tox-ini-fmt + - repo: meta + hooks: + - id: check-hooks-apply + - id: check-useless-excludes + ci: autoupdate_schedule: quarterly diff --git a/pyproject.toml b/pyproject.toml index 70195bd..bbf2520 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"] diff --git a/scripts/run_command.py b/scripts/run_command.py index 8a7d5af..eab6d9e 100644 --- a/scripts/run_command.py +++ b/scripts/run_command.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import shlex import subprocess diff --git a/src/em_keyboard/__init__.py b/src/em_keyboard/__init__.py index 0122c04..9fd2b9d 100644 --- a/src/em_keyboard/__init__.py +++ b/src/em_keyboard/__init__.py @@ -12,7 +12,7 @@ automatically added to your clipboard. - ✨ 🍰 ✨ (sparkles shortcake sparkles) """ - +from __future__ import annotations import argparse import importlib.metadata diff --git a/tests/test_em.py b/tests/test_em.py index a8f665c..6fad91d 100644 --- a/tests/test_em.py +++ b/tests/test_em.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import argparse import random from unittest.mock import call, patch From c2317bad72ca673ba55db1e67e7ccfd4e063d4b3 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sat, 9 Dec 2023 15:21:18 +0200 Subject: [PATCH 3/3] Add Prettier --- .pre-commit-config.yaml | 7 +++++++ README.md | 10 ++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6ad2236..6deb1b4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,6 +40,13 @@ 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 diff --git a/README.md b/README.md index 04577b0..a4efeae 100644 --- a/README.md +++ b/README.md @@ -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.