-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dev: swap black to ruff, drop pre-commit
now that ruff has formatting capabilities, we can drop one more dependency. Also, the version of black and ruff in the pre-commit config was out of sync from the version pinned in pdm.lock. That is bad. So just drop pre-commit, and run stuff manually, there are only a few commands. But I can't remove it entirely, since pre-commit.ci is enabled on all jazzband repos and I can't turn it off. So there needs to be some content in there, so I added some of the generic builtin ones. I had to adjust a few of the example docstrings so that ruff wouldn't autoformat away the needed leading indentation. I was lazy and just added a bunch of `# noqa: E721` for the `type(match.value) == str` checks that should be isinstance() checks, because when I tried isinstance, some tests failed. The current method isn't that egregious.
- Loading branch information
Showing
27 changed files
with
482 additions
and
418 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
.* | ||
!.github | ||
!.gitignore | ||
!.pre-commit-config.yaml | ||
|
||
*.py[co] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,26 @@ | ||
repos: | ||
- repo: https://github.com/psf/black | ||
rev: 23.3.0 | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: black | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.0.270 | ||
hooks: | ||
- id: ruff | ||
- id: check-added-large-files # prevents giant files from being committed. | ||
- id: check-ast # simply checks whether the files parse as valid python. | ||
- id: check-byte-order-marker # forbids files which have a utf-8 byte-order marker. | ||
- id: check-case-conflict # checks for files that would conflict in case-insensitive filesystems. | ||
- id: check-executables-have-shebangs # ensures that (non-binary) executables have a shebang. | ||
- id: check-json # checks json files for parseable syntax. | ||
- id: check-shebang-scripts-are-executable # ensures that (non-binary) files with a shebang are executable. | ||
- id: pretty-format-json # sets a standard for formatting json files. | ||
- id: check-merge-conflict # checks for files that contain merge conflict strings. | ||
- id: check-symlinks # checks for symlinks which do not point to anything. | ||
- id: check-toml # checks toml files for parseable syntax. | ||
- id: check-vcs-permalinks # ensures that links to vcs websites are permalinks. | ||
- id: check-xml # checks xml files for parseable syntax. | ||
- id: check-yaml # checks yaml files for parseable syntax. | ||
- id: debug-statements # checks for debugger imports and py37+ `breakpoint()` calls in python source. | ||
- id: destroyed-symlinks # detects symlinks which are changed to regular files with a content of a path which that symlink was pointing to. | ||
- id: detect-private-key # detects the presence of private keys. | ||
- id: end-of-file-fixer # ensures that a file is either empty, or ends with one newline. | ||
- id: fix-byte-order-marker # removes utf-8 byte order marker. | ||
- id: mixed-line-ending # replaces or checks mixed line ending. | ||
- id: sort-simple-yaml # sorts simple yaml files which consist only of top-level keys, preserving comments and blocks. | ||
- id: trailing-whitespace # trims trailing whitespace. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
* Copyright (c) 2019 itdaniher, [email protected] | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
import re | ||
|
@@ -181,21 +182,21 @@ def match( | |
return False, left, collected | ||
left_ = left[:pos] + left[(pos + 1) :] | ||
same_name = [a for a in collected if a.name == self.name] | ||
if type(self.value) == int and len(same_name) > 0: | ||
if type(self.value) == int and len(same_name) > 0: # noqa: E721 | ||
if isinstance(same_name[0].value, int): | ||
same_name[0].value += 1 | ||
return True, left_, collected | ||
if type(self.value) == int and not same_name: | ||
if type(self.value) == int and not same_name: # noqa: E721 | ||
match.value = 1 | ||
return True, left_, collected + [match] | ||
if same_name and type(self.value) == list: | ||
if type(match.value) == str: | ||
if same_name and type(self.value) == list: # noqa: E721 | ||
if type(match.value) == str: # noqa: E721 | ||
increment = [match.value] | ||
if same_name[0].value is not None and increment is not None: | ||
if isinstance(same_name[0].value, type(increment)): | ||
same_name[0].value += increment | ||
return True, left_, collected | ||
elif not same_name and type(self.value) == list: | ||
elif not same_name and type(self.value) == list: # noqa: E721 | ||
if isinstance(match.value, str): | ||
match.value = [match.value] | ||
return True, left_, collected + [match] | ||
|
@@ -238,7 +239,7 @@ def fix_repeating_arguments(self) -> _BranchPattern: | |
if type(e) is _Argument or type(e) is _Option and e.argcount: | ||
if e.value is None: | ||
e.value = [] | ||
elif type(e.value) is not list: | ||
elif type(e.value) is not list: # noqa: E721 | ||
e.value = cast(str, e.value) | ||
e.value = e.value.split() | ||
if type(e) is _Command or type(e) is _Option and e.argcount == 0: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.