Skip to content

Commit

Permalink
chore(pre-commit): update hooks and add new linting and formatting to…
Browse files Browse the repository at this point in the history
…ols (#176)

* chore(pre-commit): update hooks and add new linting and formatting tools

* chore(deps): remove unused dependencies from lock file

* chore(deps): remove unused dependency and update autopep8 configuration

* chore: remove unnecessary line from pull request template

* chore: add blank line for improved readability in event handler

* test: enhance sanitization filter tests for log messages

* chore: remove unused myst_enable_extensions configuration
  • Loading branch information
MountainGod2 authored Dec 30, 2024
1 parent 16e4f2f commit 081e4c7
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 38 deletions.
1 change: 0 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@


* **Other information**:

33 changes: 21 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.1 # Ruff version
hooks:
- id: ruff # Linting
args: [ --fix ]
- id: ruff-format # Formatting
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: debug-statements
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.1
hooks:
- id: pyupgrade
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.1
hooks:
- id: ruff
args:
- --fix
- id: ruff-format
- repo: https://github.com/hhatto/autopep8
rev: v2.3.1
hooks:
- id: autopep8
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
]
version = __version__
release = __version__
myst_enable_extensions = ["linkify"]
napoleon_google_docstring = True
napoleon_numpy_docstring = False
autoapi_dirs = ["../src"]
Expand Down
1 change: 1 addition & 0 deletions examples/event_handler_large_tips.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ async def main():
if event.method == "tip": # Check if the event is a tip event
tip = event.object.tip
user = event.object.user

if tip and user:
await handle_large_tip(tip, user) # Handle the large tip

Expand Down
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ dev = [

[project.optional-dependencies]
docs = [
"linkify-it-py==2.0.3",
"myst-nb==1.1.2",
"sphinx-autoapi==3.4.0",
"sphinx-rtd-theme==3.0.2",
Expand Down Expand Up @@ -91,6 +90,12 @@ ini_options.asyncio_default_fixture_loop_scope = "function"
ini_options.asyncio_mode = "strict"
ini_options.testpaths = "tests"

[tool.autopep8]
aggressive = 3
in-place = true
max_line_length = 100
recursive = true

[tool.ruff]
fix = true
format.docstring-code-format = true
Expand Down
37 changes: 37 additions & 0 deletions tests/test_logging_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def test_setup_logging(self) -> None:
def test_sanitize_filter(self) -> None:
"""Test sanitizing log messages with a filter."""
_filter = SanitizeSensitiveDataFilter()

record = logging.LogRecord(
name="test",
level=logging.INFO,
Expand All @@ -52,3 +53,39 @@ def test_sanitize_filter(self) -> None:
)
_filter.filter(record)
assert record.msg == "token=REDACTED"

record = logging.LogRecord(
name="test",
level=logging.INFO,
pathname="test.py",
lineno=10,
msg="User %s has token %s",
args=("user123", "events/username/token123"),
exc_info=None,
)
_filter.filter(record)
assert record.args == ("user123", "events/USERNAME/TOKEN")

record = logging.LogRecord(
name="test",
level=logging.INFO,
pathname="test.py",
lineno=10,
msg="Count: %d URL: %s",
args=(42, "events/user999/token888"),
exc_info=None,
)
_filter.filter(record)
assert record.args == ("42", "events/USERNAME/TOKEN")

record = logging.LogRecord(
name="test",
level=logging.INFO,
pathname="test.py",
lineno=10,
msg={"url": "events/user123/token456"},
args=(),
exc_info=None,
)
_filter.filter(record)
assert record.msg == {"url": "events/user123/token456"}
23 changes: 0 additions & 23 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 081e4c7

Please sign in to comment.