Skip to content

Commit 66baed2

Browse files
committed
style: apply nitpick settings, reformat code, fix typos
1 parent f490860 commit 66baed2

File tree

131 files changed

+542
-822
lines changed

Some content is hidden

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

131 files changed

+542
-822
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

@@ -72,7 +72,7 @@ repos:
7272
language: system
7373
types: [python]
7474
- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
75-
rev: 8d1b9cadaf854cb25bb0b0f5870e1cc66a083d6b # frozen: 0.2.3
75+
rev: 8d1b9cadaf854cb25bb0b0f5870e1cc66a083d6b # frozen: 0.2.3
7676
hooks:
7777
- id: yamlfmt
7878
args:
@@ -87,6 +87,26 @@ repos:
8787
- -e
8888
- -p
8989
- repo: https://github.com/commitizen-tools/commitizen
90-
rev: cc981fcb065527b6de0033b0cbf0432e69781901 # frozen: v4.9.1
90+
rev: cc981fcb065527b6de0033b0cbf0432e69781901 # frozen: v4.9.1
9191
hooks:
9292
- id: commitizen
93+
- repo: https://github.com/andreoliwa/nitpick
94+
rev: 'a5532d554f2c9035bb05ec14ee1bf31469e0a563' # frozen: v0.37.0
95+
hooks:
96+
- id: nitpick
97+
- repo: https://github.com/ikamensh/flynt
98+
rev: '97be693bf18bc2f050667dd282d243e2824b81e2' # frozen: 1.0.6
99+
hooks:
100+
- id: flynt
101+
- repo: https://github.com/codespell-project/codespell
102+
rev: '63c8f8312b7559622c0d82815639671ae42132ac' # frozen: v2.4.1
103+
hooks:
104+
- id: codespell
105+
exclude: data/.*
106+
additional_dependencies:
107+
- tomli ; python_version < '3.11'
108+
minimum_pre_commit_version: 2.18.0
109+
default_install_hook_types:
110+
- pre-commit
111+
- pre-push
112+
- 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
@@ -61,7 +61,7 @@ class HookDict(TypedDict):
6161
def find_hooks(parent, module) -> HookDict:
6262
hooks = defaultdict(list)
6363
for func in module.__dict__.values():
64-
if hasattr(func, HOOK_ATTR) and not hasattr(func, "_not_" + HOOK_ATTR):
64+
if hasattr(func, HOOK_ATTR) and not hasattr(func, f"_not_{HOOK_ATTR}"):
6565
# if it has cloudbot hook
6666
func_hooks = getattr(func, HOOK_ATTR)
6767

@@ -152,7 +152,7 @@ def find_plugin(self, title):
152152
return self._plugin_name_map.get(title)
153153

154154
def safe_resolve(self, path_obj: Path) -> Path:
155-
"""Resolve the parts of a path that exist, allowing a non-existant path
155+
"""Resolve the parts of a path that exist, allowing a non-existent path
156156
to be resolved to allow resolution of its parents
157157
158158
:param path_obj: The `Path` object to resolve

0 commit comments

Comments
 (0)