Skip to content

Commit

Permalink
Update pre-commit hooks, enable more ruff rules, and minor metadata c…
Browse files Browse the repository at this point in the history
…hanges
  • Loading branch information
CoolCat467 committed Dec 14, 2023
1 parent b50d4df commit d9b23ee
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ repos:
types: [file]
types_or: [python, pyi]
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.11.0
rev: 23.12.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.7
rev: v0.1.8
hooks:
- id: ruff
types: [file]
Expand Down
77 changes: 55 additions & 22 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@ idlemypyextension = "idlemypyextension:check_installed"
[tool.setuptools.package-data]
idlemypyextension = ["py.typed"]

[tool.pytest.ini_options]
addopts = "--cov-report term-missing --cov=idlemypyextension"
testpaths = [
"tests",
]

[tool.mypy]
mypy_path = "src"
check_untyped_defs = true
Expand All @@ -78,41 +72,80 @@ warn_unreachable = true
warn_unused_configs = true
warn_unused_ignores = true

[tool.black]
line-length = 79
target-version = ['py311']

[tool.ruff.isort]
combine-as-imports = true

[tool.pycln]
all = true
disable_all_dunder_policy = true

[tool.ruff.per-file-ignores]
"tests/*" = ["D103"]
[tool.black]
line-length = 79
target-version = ['py311']

[tool.ruff]
line-length = 79
fix = true

include = ["*.py", "*.pyi", "**/pyproject.toml"]

select = ['A', 'B', 'C4', 'COM', 'D', 'E', 'EXE', 'F', 'FA', 'I', 'N', 'PIE', 'PT', 'PYI', 'Q', 'RET', 'RUF', 'S', 'SIM', 'SLOT', 'UP', 'YTT']
select = [
"A", # flake8-builtins
"ASYNC", # flake8-async
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"COM", # flake8-commas
"D", # pydocstyle
"E", # Error
"EXE", # flake8-executable
"F", # pyflakes
"FA", # flake8-future-annotations
"I", # isort
"N", # pep8-naming
"PIE", # flake8-pie
"PT", # flake8-pytest-style
"PYI", # flake8-pyi
"Q", # flake8-quotes
"RET", # flake8-return
"RUF", # Ruff-specific rules
"S", # flake8-bandit
"SIM", # flake8-simplify
"SLOT", # flake8-slots
"TCH", # flake8-type-checking
"UP", # pyupgrade
"W", # Warning
"YTT", # flake8-2020
]
ignore = [
"D211", # conflicts with docstrings
"D213", # conflicts with docstrings
'E501', # line-too-long
"S101", # use of assert for tests and type narrowing
"D203", # One blank line before class
"D204", # blank line thing
"D211", # no-blank-line-before-class
"D213", # multi-line-summary-second-line
## "E203", # conflicts with black
"E501", # line-too-long
"S101", # use of assert for tests and type narrowing
## "E402", # module level import not at top of file
"D203", # One blank line before class
"D401", # Imparative mood docstrings
"D417", # Bugged "Missing argument descriptions in the docstring"
"SIM117", # Use multiple with statements at the same time
"D417", # "Missing argument descriptions"
]

[tool.ruff.per-file-ignores]
"tests/*" = [
"D100", # undocumented-public-module
"D103", # undocumented-public-function
"D107", # Missing docstring
]

[tool.pytest.ini_options]
addopts = "--cov-report term-missing --cov=idlemypyextension"
testpaths = [
"tests",
]

fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"]
unfixable = []#"D203"]
[tool.coverage.run]
branch = true
source = ["src"]
omit = []

[tool.tox]
legacy_tox_ini = """
Expand Down
10 changes: 6 additions & 4 deletions src/idlemypyextension/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,18 @@
from functools import partial, wraps
from idlelib import search, searchengine
from idlelib.config import idleConf
from idlelib.editor import EditorWindow
from idlelib.format import FormatRegion
from idlelib.iomenu import IOBinding
from idlelib.pyshell import PyShellEditorWindow, PyShellFileList
from idlelib.undo import UndoDelegator
from tkinter import Event, Text, Tk, messagebox
from typing import Any, ClassVar, Final, TypeVar, cast
from typing import TYPE_CHECKING, Any, ClassVar, Final, TypeVar, cast

from idlemypyextension import annotate, tktrio

if TYPE_CHECKING:
from idlelib.editor import EditorWindow
from idlelib.undo import UndoDelegator

DAEMON_TIMEOUT_MIN: Final = 5
ACTION_TIMEOUT_MIN: Final = 5

Expand Down Expand Up @@ -1215,7 +1217,7 @@ class _FakeText(Text):
"""Make bind do nothing."""

def __init__(self) -> None:
"""Requires no arguments."""
"""Blank Initialize."""
return

bind = lambda x, y: None # type: ignore[assignment] # noqa
Expand Down
6 changes: 4 additions & 2 deletions src/idlemypyextension/annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@


import re
from collections.abc import Callable, Collection, Generator, Sequence
from tokenize import TokenInfo, generate_tokens, tok_name
from typing import Any, Final, NamedTuple, NoReturn
from typing import TYPE_CHECKING, Any, Final, NamedTuple, NoReturn

if TYPE_CHECKING:
from collections.abc import Callable, Collection, Generator, Sequence

TYPING_LOWER: Final = {"List", "Set", "Type", "Dict", "Tuple", "Overload"}

Expand Down
6 changes: 4 additions & 2 deletions src/idlemypyextension/ast_annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
import ast
import re
import tokenize
from collections.abc import Callable, Collection, Sequence
from typing import Any, Final, NamedTuple, NoReturn
from typing import TYPE_CHECKING, Any, Final, NamedTuple, NoReturn

if TYPE_CHECKING:
from collections.abc import Callable, Collection, Sequence

TYPING_LOWER: Final = {"List", "Set", "Type", "Dict", "Tuple", "Overload"}

Expand Down
3 changes: 2 additions & 1 deletion src/idlemypyextension/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import os
import sys
from collections import ChainMap
from collections.abc import Sequence
from typing import TYPE_CHECKING, TypedDict, cast

from idlemypyextension.moduleguard import guard_imports
Expand All @@ -64,6 +63,8 @@
from mypy.version import __version__

if TYPE_CHECKING:
from collections.abc import Sequence

from typing_extensions import NotRequired


Expand Down
5 changes: 3 additions & 2 deletions src/idlemypyextension/moduleguard.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
import json
import os
import sys
from collections.abc import Iterable
from types import TracebackType
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from collections.abc import Iterable
from types import TracebackType

from typing_extensions import Self


Expand Down
2 changes: 1 addition & 1 deletion src/idlemypyextension/tktrio.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def _start_async_task(
self,
function: Callable[[], Awaitable[Any]],
) -> None:
"""Internal start task running so except block can catch errors."""
"""Run async task in new nursery."""
if evil_does_trio_have_runner():
self.show_warning_trio_already_running()
return
Expand Down
5 changes: 4 additions & 1 deletion tests/test_annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
from __future__ import annotations

import sys
from collections.abc import Collection, Sequence
from typing import TYPE_CHECKING

import pytest
from idlemypyextension import annotate

if TYPE_CHECKING:
from collections.abc import Collection, Sequence


def test_parse_error() -> None:
with pytest.raises(annotate.ParseError, match=""):
Expand Down

0 comments on commit d9b23ee

Please sign in to comment.