Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ root = true

# All files.
[*]
end_of_line = LF
end_of_line = lf
indent_style = space
indent_size = 4

Expand All @@ -17,5 +17,11 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{yml,yaml}]
[*.{bat,cmd,ps1}]
end_of_line = crlf

[*.{js,json,json5,yml,yaml,md,rb}]
indent_size = 2

[Makefile]
indent_style = tab
10 changes: 9 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,18 @@ jobs:
pip install -U pip wheel
pip install -Ur requirements-dev.txt

- name: cache pre-commit
uses: actions/[email protected]
with:
path: ~/.cache/pre-commit
key: pre-commit-${{runner.os}}-${{matrix.python-ver}}
restore-keys: |
pre-commit-${{runner.os}}-

- name: Run pre-commit
run: pre-commit run --all
env:
SKIP: yamlfmt
SKIP: yamlfmt,nitpick

- name: Run yamlfmt
if: runner.os != 'Windows'
Expand Down
41 changes: 33 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ci:
exclude: ^\.vscode/.*$
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # frozen: v6.0.0
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # frozen: v6.0.0
hooks:
- id: trailing-whitespace
args: ['--markdown-linebreak-ext=md,markdown']
Expand Down Expand Up @@ -33,26 +33,26 @@ repos:
- --no-sort-keys
- id: check-toml
- repo: https://github.com/psf/black
rev: af0ba72a73598c76189d6dd1b21d8532255d5942 # frozen: 25.9.0
rev: af0ba72a73598c76189d6dd1b21d8532255d5942 # frozen: 25.9.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 0a09c783808cfe77bb3269250f663ff733d23302 # frozen: 7.0.0
rev: 0a09c783808cfe77bb3269250f663ff733d23302 # frozen: 7.0.0
hooks:
- id: isort
- repo: https://github.com/pre-commit/pygrep-hooks
rev: 3a6eb0fadf60b3cccfd80bad9dbb6fae7e47b316 # frozen: v1.10.0
rev: 3a6eb0fadf60b3cccfd80bad9dbb6fae7e47b316 # frozen: v1.10.0
hooks:
- id: python-no-eval
- id: python-no-log-warn
- repo: https://github.com/asottile/pyupgrade
rev: f90119b1b8bd9e46949d9592972b2c4c27d62a97 # frozen: v3.21.0
rev: f90119b1b8bd9e46949d9592972b2c4c27d62a97 # frozen: v3.21.0
hooks:
- id: pyupgrade
args:
- "--py310-plus"
- repo: https://github.com/PyCQA/autoflake
rev: 0544741e2b4a22b472d9d93e37d4ea9153820bb1 # frozen: v2.3.1
rev: 0544741e2b4a22b472d9d93e37d4ea9153820bb1 # frozen: v2.3.1
hooks:
- id: autoflake

Expand All @@ -72,8 +72,13 @@ repos:
exclude: alembic/.*
language: system
types: [python]
- id: replace-non-ascii
name: replace non ascii characters
entry: python3 tools/escape_non_ascii.py
language: python
types: [python]
- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
rev: 8d1b9cadaf854cb25bb0b0f5870e1cc66a083d6b # frozen: 0.2.3
rev: 8d1b9cadaf854cb25bb0b0f5870e1cc66a083d6b # frozen: 0.2.3
hooks:
- id: yamlfmt
args:
Expand All @@ -88,6 +93,26 @@ repos:
- -e
- -p
- repo: https://github.com/commitizen-tools/commitizen
rev: cc981fcb065527b6de0033b0cbf0432e69781901 # frozen: v4.9.1
rev: cc981fcb065527b6de0033b0cbf0432e69781901 # frozen: v4.9.1
hooks:
- id: commitizen
- repo: https://github.com/andreoliwa/nitpick
rev: 'a5532d554f2c9035bb05ec14ee1bf31469e0a563' # frozen: v0.37.0
hooks:
- id: nitpick
- repo: https://github.com/ikamensh/flynt
rev: '97be693bf18bc2f050667dd282d243e2824b81e2' # frozen: 1.0.6
hooks:
- id: flynt
- repo: https://github.com/codespell-project/codespell
rev: '63c8f8312b7559622c0d82815639671ae42132ac' # frozen: v2.4.1
hooks:
- id: codespell
exclude: data/.*
additional_dependencies:
- tomli ; python_version < '3.11'
minimum_pre_commit_version: 2.18.0
default_install_hook_types:
- pre-commit
- pre-push
- commit-msg
10 changes: 7 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@
"editor.defaultFormatter": "ms-python.black-formatter"
},
"evenBetterToml.formatter.allowedBlankLines": 1,
"evenBetterToml.formatter.arrayAutoCollapse": true,
"evenBetterToml.formatter.arrayAutoExpand": false,
"evenBetterToml.formatter.arrayAutoCollapse": false,
"evenBetterToml.formatter.arrayAutoExpand": true,
"evenBetterToml.formatter.arrayTrailingComma": true,
"python-envs.defaultEnvManager": "ms-python.python:system",
"python-envs.pythonProjects": [],
"python.analysis.diagnosticMode": "workspace"
"python.analysis.diagnosticMode": "workspace",
"evenBetterToml.formatter.columnWidth": 60,
"[toml]": {
"editor.defaultFormatter": "tamasfe.even-better-toml"
}
}
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ submit a pull request.
This project uses [pre-commit]
1. [Install pre-commit]
2. Run `pre-commit install` to add it as a git precommit hook to run checks on each `git commit` in the repository
3. Run `pre-commit run` before commiting, to check your changes easily
3. Run `pre-commit run` before committing, to check your changes easily

## Submit Changes
1. Push your changes to a topic branch in your fork of the repository.
Expand Down
4 changes: 1 addition & 3 deletions cloudbot/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ def _decorate(cls):
class ClientConnectError(Exception):
def __init__(self, client_name, server):
super().__init__(
"Unable to connect to client {} with server {}".format(
client_name, server
)
f"Unable to connect to client {client_name} with server {server}"
)
self.client_name = client_name
self.server = server
Expand Down
4 changes: 2 additions & 2 deletions cloudbot/clients/irc.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ async def send(self, line, log=True):

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

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

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

# Parse the command and params
# Content
Expand Down
10 changes: 3 additions & 7 deletions cloudbot/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ async def close(self):

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

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

if self.hook.doc is None:
message = "{}{} requires additional arguments.".format(
self.triggered_prefix, self.triggered_command
)
message = f"{self.triggered_prefix}{self.triggered_command} requires additional arguments."
else:
message = "{}{} {}".format(
self.triggered_prefix, self.triggered_command, self.hook.doc
)
message = f"{self.triggered_prefix}{self.triggered_command} {self.hook.doc}"

self.notice(message, target=target)

Expand Down
4 changes: 2 additions & 2 deletions cloudbot/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class HookDict(TypedDict):
def find_hooks(parent, module) -> HookDict:
hooks = defaultdict(list)
for func in module.__dict__.values():
if hasattr(func, HOOK_ATTR) and not hasattr(func, "_not_" + HOOK_ATTR):
if hasattr(func, HOOK_ATTR) and not hasattr(func, f"_not_{HOOK_ATTR}"):
# if it has cloudbot hook
func_hooks = getattr(func, HOOK_ATTR)

Expand Down Expand Up @@ -94,7 +94,7 @@ def find_tables(code):


def safe_resolve(path_obj: Path) -> Path:
"""Resolve the parts of a path that exist, allowing a non-existant path
"""Resolve the parts of a path that exist, allowing a non-existent path
to be resolved to allow resolution of its parents

:param path_obj: The `Path` object to resolve
Expand Down
Loading