Skip to content

Commit 88584d3

Browse files
committed
style: apply nitpick settings, reformat code, fix typos
1 parent f1a0b79 commit 88584d3

File tree

133 files changed

+889
-846
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+889
-846
lines changed

.editorconfig

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ root = true
77

88
# All files.
99
[*]
10-
end_of_line = LF
10+
end_of_line = lf
1111
indent_style = space
1212
indent_size = 4
1313

@@ -17,5 +17,11 @@ charset = utf-8
1717
trim_trailing_whitespace = true
1818
insert_final_newline = true
1919

20-
[*.{yml,yaml}]
20+
[*.{bat,cmd,ps1}]
21+
end_of_line = crlf
22+
23+
[*.{js,json,json5,yml,yaml,md,rb}]
2124
indent_size = 2
25+
26+
[Makefile]
27+
indent_style = tab

.github/workflows/tests.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,18 @@ jobs:
6363
pip install -U pip wheel
6464
pip install -Ur requirements-dev.txt
6565
66+
- name: cache pre-commit
67+
uses: actions/[email protected]
68+
with:
69+
path: ~/.cache/pre-commit
70+
key: pre-commit-${{runner.os}}-${{matrix.python-ver}}
71+
restore-keys: |
72+
pre-commit-${{runner.os}}-
73+
6674
- name: Run pre-commit
6775
run: pre-commit run --all
6876
env:
69-
SKIP: yamlfmt
77+
SKIP: yamlfmt,nitpick
7078

7179
- name: Run yamlfmt
7280
if: runner.os != 'Windows'

.pre-commit-config.yaml

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ci:
55
exclude: ^\.vscode/.*$
66
repos:
77
- repo: https://github.com/pre-commit/pre-commit-hooks
8-
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # frozen: v6.0.0
8+
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # frozen: v6.0.0
99
hooks:
1010
- id: trailing-whitespace
1111
args: ['--markdown-linebreak-ext=md,markdown']
@@ -33,26 +33,26 @@ repos:
3333
- --no-sort-keys
3434
- id: check-toml
3535
- repo: https://github.com/psf/black
36-
rev: af0ba72a73598c76189d6dd1b21d8532255d5942 # frozen: 25.9.0
36+
rev: af0ba72a73598c76189d6dd1b21d8532255d5942 # frozen: 25.9.0
3737
hooks:
3838
- id: black
3939
- repo: https://github.com/pycqa/isort
40-
rev: 0a09c783808cfe77bb3269250f663ff733d23302 # frozen: 7.0.0
40+
rev: 0a09c783808cfe77bb3269250f663ff733d23302 # frozen: 7.0.0
4141
hooks:
4242
- id: isort
4343
- repo: https://github.com/pre-commit/pygrep-hooks
44-
rev: 3a6eb0fadf60b3cccfd80bad9dbb6fae7e47b316 # frozen: v1.10.0
44+
rev: 3a6eb0fadf60b3cccfd80bad9dbb6fae7e47b316 # frozen: v1.10.0
4545
hooks:
4646
- id: python-no-eval
4747
- id: python-no-log-warn
4848
- repo: https://github.com/asottile/pyupgrade
49-
rev: f90119b1b8bd9e46949d9592972b2c4c27d62a97 # frozen: v3.21.0
49+
rev: f90119b1b8bd9e46949d9592972b2c4c27d62a97 # frozen: v3.21.0
5050
hooks:
5151
- id: pyupgrade
5252
args:
5353
- "--py310-plus"
5454
- repo: https://github.com/PyCQA/autoflake
55-
rev: 0544741e2b4a22b472d9d93e37d4ea9153820bb1 # frozen: v2.3.1
55+
rev: 0544741e2b4a22b472d9d93e37d4ea9153820bb1 # frozen: v2.3.1
5656
hooks:
5757
- id: autoflake
5858

@@ -73,7 +73,7 @@ repos:
7373
language: system
7474
types: [python]
7575
- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
76-
rev: 8d1b9cadaf854cb25bb0b0f5870e1cc66a083d6b # frozen: 0.2.3
76+
rev: 8d1b9cadaf854cb25bb0b0f5870e1cc66a083d6b # frozen: 0.2.3
7777
hooks:
7878
- id: yamlfmt
7979
args:
@@ -88,6 +88,26 @@ repos:
8888
- -e
8989
- -p
9090
- repo: https://github.com/commitizen-tools/commitizen
91-
rev: cc981fcb065527b6de0033b0cbf0432e69781901 # frozen: v4.9.1
91+
rev: cc981fcb065527b6de0033b0cbf0432e69781901 # frozen: v4.9.1
9292
hooks:
9393
- id: commitizen
94+
- repo: https://github.com/andreoliwa/nitpick
95+
rev: 'a5532d554f2c9035bb05ec14ee1bf31469e0a563' # frozen: v0.37.0
96+
hooks:
97+
- id: nitpick
98+
- repo: https://github.com/ikamensh/flynt
99+
rev: '97be693bf18bc2f050667dd282d243e2824b81e2' # frozen: 1.0.6
100+
hooks:
101+
- id: flynt
102+
- repo: https://github.com/codespell-project/codespell
103+
rev: '63c8f8312b7559622c0d82815639671ae42132ac' # frozen: v2.4.1
104+
hooks:
105+
- id: codespell
106+
exclude: data/.*
107+
additional_dependencies:
108+
- tomli ; python_version < '3.11'
109+
minimum_pre_commit_version: 2.18.0
110+
default_install_hook_types:
111+
- pre-commit
112+
- pre-push
113+
- commit-msg

.vscode/settings.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@
1212
"editor.defaultFormatter": "ms-python.black-formatter"
1313
},
1414
"evenBetterToml.formatter.allowedBlankLines": 1,
15-
"evenBetterToml.formatter.arrayAutoCollapse": true,
16-
"evenBetterToml.formatter.arrayAutoExpand": false,
15+
"evenBetterToml.formatter.arrayAutoCollapse": false,
16+
"evenBetterToml.formatter.arrayAutoExpand": true,
1717
"evenBetterToml.formatter.arrayTrailingComma": true,
1818
"python-envs.defaultEnvManager": "ms-python.python:system",
1919
"python-envs.pythonProjects": [],
20-
"python.analysis.diagnosticMode": "workspace"
20+
"python.analysis.diagnosticMode": "workspace",
21+
"evenBetterToml.formatter.columnWidth": 60,
22+
"[toml]": {
23+
"editor.defaultFormatter": "tamasfe.even-better-toml"
24+
}
2125
}

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ submit a pull request.
1717
This project uses [pre-commit]
1818
1. [Install pre-commit]
1919
2. Run `pre-commit install` to add it as a git precommit hook to run checks on each `git commit` in the repository
20-
3. Run `pre-commit run` before commiting, to check your changes easily
20+
3. Run `pre-commit run` before committing, to check your changes easily
2121

2222
## Submit Changes
2323
1. Push your changes to a topic branch in your fork of the repository.

cloudbot/client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ def _decorate(cls):
2121
class ClientConnectError(Exception):
2222
def __init__(self, client_name, server):
2323
super().__init__(
24-
"Unable to connect to client {} with server {}".format(
25-
client_name, server
26-
)
24+
f"Unable to connect to client {client_name} with server {server}"
2725
)
2826
self.client_name = client_name
2927
self.server = server

cloudbot/clients/irc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ async def send(self, line, log=True):
492492

493493
if not filtered:
494494
# No outgoing sieves loaded or one of the sieves errored, fall back to old behavior
495-
line = old_line[:510] + "\r\n"
495+
line = f"{old_line[:510]}\r\n"
496496
line = line.encode("utf-8", "replace")
497497

498498
if not isinstance(line, bytes):
@@ -531,7 +531,7 @@ def parse_line(self, line: str) -> Event:
531531

532532
# Reply to pings immediately
533533
if command == "PING":
534-
self.conn.send("PONG " + command_params[-1], log=False)
534+
self.conn.send(f"PONG {command_params[-1]}", log=False)
535535

536536
# Parse the command and params
537537
# Content

cloudbot/event.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ async def close(self):
189189

190190
if self.db is not None:
191191
# logger.debug("Closing database session for {}:threaded=False".format(self.hook.description))
192-
# be sure the close the database in the database executor, as it is only accessable in that one thread
192+
# be sure the close the database in the database executor, as it is only accessible in that one thread
193193
await self.async_call(self.db.close)
194194
self.db = None
195195

@@ -425,13 +425,9 @@ def notice_doc(self, target=None):
425425
raise ValueError("Triggered command not set on this event")
426426

427427
if self.hook.doc is None:
428-
message = "{}{} requires additional arguments.".format(
429-
self.triggered_prefix, self.triggered_command
430-
)
428+
message = f"{self.triggered_prefix}{self.triggered_command} requires additional arguments."
431429
else:
432-
message = "{}{} {}".format(
433-
self.triggered_prefix, self.triggered_command, self.hook.doc
434-
)
430+
message = f"{self.triggered_prefix}{self.triggered_command} {self.hook.doc}"
435431

436432
self.notice(message, target=target)
437433

cloudbot/plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class HookDict(TypedDict):
6262
def find_hooks(parent, module) -> HookDict:
6363
hooks = defaultdict(list)
6464
for func in module.__dict__.values():
65-
if hasattr(func, HOOK_ATTR) and not hasattr(func, "_not_" + HOOK_ATTR):
65+
if hasattr(func, HOOK_ATTR) and not hasattr(func, f"_not_{HOOK_ATTR}"):
6666
# if it has cloudbot hook
6767
func_hooks = getattr(func, HOOK_ATTR)
6868

@@ -94,7 +94,7 @@ def find_tables(code):
9494

9595

9696
def safe_resolve(path_obj: Path) -> Path:
97-
"""Resolve the parts of a path that exist, allowing a non-existant path
97+
"""Resolve the parts of a path that exist, allowing a non-existent path
9898
to be resolved to allow resolution of its parents
9999
100100
:param path_obj: The `Path` object to resolve

0 commit comments

Comments
 (0)