Skip to content

Commit

Permalink
👷 Use ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Feb 19, 2024
1 parent 918d4d5 commit 239ce17
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 59 deletions.
38 changes: 9 additions & 29 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ repos:
hooks:
- id: actionlint
- repo: https://github.com/adrienverge/yamllint
rev: v1.33.0
rev: v1.35.1
hooks:
- id: yamllint
- repo: https://github.com/executablebooks/mdformat
Expand All @@ -65,44 +65,24 @@ repos:
- mdformat-toc
- mdformat-deflist
- mdformat-beautysh
- mdformat-black
- mdformat-ruff
- mdformat-config
- mdformat-web
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.11.0
rev: v0.12.1
hooks:
- id: markdownlint-cli2
additional_dependencies:
- markdown-it-texmath
- repo: https://github.com/psf/black
rev: 23.11.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/pycqa/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle
additional_dependencies:
- tomli
- id: ruff
- id: ruff-format
- repo: https://github.com/kumaraditya303/mirrors-pyright
rev: v1.1.338
rev: v1.1.350
hooks:
- id: pyright
- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
hooks:
- id: bandit
args:
- -cpyproject.toml
additional_dependencies:
- tomli
- repo: https://github.com/nix-community/nixpkgs-fmt
rev: v1.3.0
hooks:
- id: nixpkgs-fmt

ci:
skip:
Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
https://www.sphinx-doc.org/en/master/usage/configuration.html
"""

from tmux_language_server import __version__ as version # type: ignore
from tmux_language_server._metainfo import ( # type: ignore
author,
Expand Down
58 changes: 31 additions & 27 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
[build-system]
requires = [
"setuptools_scm[toml] >= 6.2",
"setuptools-generate >= 0.0.6",
"platformdirs",
]
requires = ["setuptools_scm[toml] >= 6.2", "setuptools-generate >= 0.0.6"]
build-backend = "setuptools.build_meta"

# https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html
[project]
name = "tmux-language-server"
description = "tmux language server"
readme = "README.md"
requires-python = ">= 3.7"
# type_a | type_b
requires-python = ">= 3.10"
keywords = ["tmux", "language server"]
classifiers = [
"Development Status :: 3 - Alpha",
Expand All @@ -24,11 +21,9 @@ classifiers = [
"Operating System :: MacOS",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
Expand Down Expand Up @@ -62,6 +57,9 @@ tmux_language_server = ["py.typed", "assets/**"]
file = "requirements.txt"

# begin: scripts/update-pyproject.toml.pl
[tool.setuptools.dynamic.optional-dependencies.colorize]
file = "requirements/colorize.txt"

[tool.setuptools.dynamic.optional-dependencies.dev]
file = "requirements/dev.txt"

Expand All @@ -81,31 +79,37 @@ file = "templates/metainfo.py.j2"
[tool.mdformat]
number = true

[tool.black]
line-length = 79
[tool.doq]
template_path = "templates"

[tool.isort]
line_length = 79
profile = "black"
[tool.ruff]
line-length = 79

# https://github.com/PyCQA/pydocstyle/issues/418
[tool.pydocstyle]
add_ignore = "D205, D400"
[tool.ruff.lint]
select = [
# pycodestyle
"E",
# pyflakes
"F",
# pyupgrade
"UP",
# flake8-bugbear
"B",
# flake8-simplify
"SIM",
# isort
"I",
]
ignore = ["D205", "D400"]
preview = true

[tool.doq]
template_path = "templates"
[tool.ruff.format]
docstring-code-format = true
preview = true

[tool.coverage.report]
exclude_lines = [
"if TYPE_CHECKING:",
"if __name__ == .__main__.:",
"\\s*import tomli as tomllib",
]

[tool.bandit.assert_used]
skips = ["*_test.py", "*/test_*.py"]

[tool.cibuildwheel]
archs = ["all"]
before-test = "pip install pytest"
test-command = "pytest {project}"
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env -S pip install -r

pygls
# ErrorFinder
tree-sitter-lsp >= 0.0.13
tree-sitter-tmux
1 change: 1 addition & 0 deletions src/tmux_language_server/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
r"""Provide ``__version__`` for
`importlib.metadata.version() <https://docs.python.org/3/library/importlib.metadata.html#distribution-versions>`_.
"""

try:
from ._version import __version__, __version_tuple__ # type: ignore
except ImportError: # for setuptools-generate
Expand Down
1 change: 1 addition & 0 deletions src/tmux_language_server/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
r"""This module can be called by
`python -m <https://docs.python.org/3/library/__main__.html>`_.
"""

import logging
from argparse import ArgumentParser, RawDescriptionHelpFormatter
from contextlib import suppress
Expand Down
6 changes: 5 additions & 1 deletion src/tmux_language_server/misc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
r"""Misc
========
"""

import re
from typing import Any

Expand All @@ -20,7 +21,10 @@ def get_schema() -> dict[str, Any]:
"""
filetype = "tmux"
schema = {
"$id": f"{SOURCE}/blob/main/src/termux_language_server/assets/json/{filetype}.json",
"$id": (
f"{SOURCE}/blob/main/"
f"src/termux_language_server/assets/json/{filetype}.json"
),
"$schema": "http://json-schema.org/draft-07/schema#",
"$comment": (
"Don't edit this file directly! It is generated by "
Expand Down
1 change: 1 addition & 0 deletions src/tmux_language_server/server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
r"""Server
==========
"""

import re
from typing import Any

Expand Down
3 changes: 2 additions & 1 deletion src/tmux_language_server/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
r"""Utils
=========
"""

import json
import os
from typing import Any
Expand All @@ -23,6 +24,6 @@ def get_schema(filetype: str = "tmux") -> dict[str, Any]:
),
f"{filetype}.json",
)
with open(file, "r") as f:
with open(file) as f:
SCHEMAS[filetype] = json.load(f)
return SCHEMAS[filetype]
1 change: 1 addition & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
r"""Test utils."""

from tmux_language_server.utils import get_schema


Expand Down

0 comments on commit 239ce17

Please sign in to comment.