-
-
Notifications
You must be signed in to change notification settings - Fork 23
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. This also means that pre-commit is a bit overkill. 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. 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
26 changed files
with
349 additions
and
481 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,3 @@ | ||
repos: | ||
- repo: https://github.com/psf/black | ||
rev: 23.3.0 | ||
hooks: | ||
- id: black | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.0.270 | ||
hooks: | ||
- id: ruff | ||
# Empty just to make the CI runs happy, since I can't turn off pre-commit.ci | ||
# on just this repo, it is enabled for all jazzband repos. | ||
# Run the checks manually per the README. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,8 @@ | |
Options: | ||
-h, --help | ||
""" | ||
|
||
from docopt import docopt | ||
|
||
if __name__ == "__main__": | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,8 @@ | |
Options: | ||
-h, --help | ||
""" | ||
|
||
from docopt import docopt | ||
|
||
if __name__ == "__main__": | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,8 @@ | |
Options: | ||
--count=N number of operations | ||
""" | ||
|
||
import os | ||
|
||
from docopt import docopt | ||
|
Oops, something went wrong.