Skip to content

Commit 9473956

Browse files
[pre-commit.ci] pre-commit autoupdate (#8)
<!--pre-commit.ci start--> updates: - [github.com/pre-commit/pre-commit-hooks: v4.4.0 → v6.0.0](pre-commit/pre-commit-hooks@v4.4.0...v6.0.0) - https://github.com/psf/blackhttps://github.com/psf/black-pre-commit-mirror - [github.com/psf/black-pre-commit-mirror: 23.7.0 → 26.1.0](psf/black-pre-commit-mirror@23.7.0...26.1.0) - [github.com/pycqa/flake8: 6.0.0 → 7.3.0](PyCQA/flake8@6.0.0...7.3.0) - [github.com/pycqa/isort: 5.12.0 → 7.0.0](PyCQA/isort@5.12.0...7.0.0) - [github.com/Yelp/detect-secrets: v1.4.0 → v1.5.0](Yelp/detect-secrets@v1.4.0...v1.5.0) - [github.com/pre-commit/mirrors-mypy: v1.4.1 → v1.19.1](pre-commit/mirrors-mypy@v1.4.1...v1.19.1) <!--pre-commit.ci end--> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent e07235d commit 9473956

3 files changed

Lines changed: 22 additions & 34 deletions

File tree

.pre-commit-config.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.4.0
3+
rev: v6.0.0
44
hooks:
55
- id: trailing-whitespace
66
- id: end-of-file-fixer
@@ -10,27 +10,27 @@ repos:
1010
- id: debug-statements
1111
- id: check-executables-have-shebangs
1212

13-
- repo: https://github.com/psf/black
14-
rev: 23.7.0
13+
- repo: https://github.com/psf/black-pre-commit-mirror
14+
rev: 26.1.0
1515
hooks:
1616
- id: black
1717
language_version: python3
1818
args: [--line-length=180]
1919

2020
- repo: https://github.com/pycqa/flake8
21-
rev: 6.0.0
21+
rev: 7.3.0
2222
hooks:
2323
- id: flake8
2424
args: ['--max-line-length=180', '--ignore=E203,W503,E231,E226,E241,E722,F401,F403,F405,F541,F811,E402']
2525

2626
- repo: https://github.com/pycqa/isort
27-
rev: 5.12.0
27+
rev: 7.0.0
2828
hooks:
2929
- id: isort
3030
args: [--profile=black]
3131

3232
- repo: https://github.com/Yelp/detect-secrets
33-
rev: v1.4.0
33+
rev: v1.5.0
3434
hooks:
3535
- id: detect-secrets
3636
args: ['--baseline', '.secrets.baseline']
@@ -44,7 +44,7 @@ repos:
4444
)$
4545
4646
- repo: https://github.com/pre-commit/mirrors-mypy
47-
rev: v1.4.1
47+
rev: v1.19.1
4848
hooks:
4949
- id: mypy
5050
additional_dependencies: [types-requests]

modlog_wiki_publisher.py

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Reddit Modlog Wiki Publisher
44
Scrapes moderation logs and publishes them to a subreddit wiki page
55
"""
6+
67
import argparse
78
import hashlib
89
import json
@@ -111,12 +112,10 @@ def get_db_version():
111112
cursor = conn.cursor()
112113

113114
# Check if version table exists
114-
cursor.execute(
115-
"""
115+
cursor.execute("""
116116
SELECT name FROM sqlite_master
117117
WHERE type='table' AND name='schema_version'
118-
"""
119-
)
118+
""")
120119

121120
if not cursor.fetchone():
122121
conn.close()
@@ -138,15 +137,13 @@ def set_db_version(version):
138137
conn = sqlite3.connect(DB_PATH)
139138
cursor = conn.cursor()
140139

141-
cursor.execute(
142-
"""
140+
cursor.execute("""
143141
CREATE TABLE IF NOT EXISTS schema_version (
144142
id INTEGER PRIMARY KEY AUTOINCREMENT,
145143
version INTEGER NOT NULL,
146144
applied_at INTEGER DEFAULT (strftime('%s', 'now'))
147145
)
148-
"""
149-
)
146+
""")
150147

151148
cursor.execute("INSERT INTO schema_version (version) VALUES (?)", (version,))
152149
conn.commit()
@@ -245,16 +242,14 @@ def migrate_database():
245242
# Migration from version 0 to 1: Initial schema
246243
if current_version < 1:
247244
logger.info("Applying migration: Initial schema (v0 -> v1)")
248-
cursor.execute(
249-
"""
245+
cursor.execute("""
250246
CREATE TABLE IF NOT EXISTS processed_actions (
251247
id INTEGER PRIMARY KEY AUTOINCREMENT,
252248
action_id TEXT UNIQUE NOT NULL,
253249
created_at INTEGER NOT NULL,
254250
processed_at INTEGER DEFAULT (strftime('%s', 'now'))
255251
)
256-
"""
257-
)
252+
""")
258253
cursor.execute("CREATE INDEX IF NOT EXISTS idx_action_id ON processed_actions(action_id)")
259254
cursor.execute("CREATE INDEX IF NOT EXISTS idx_created_at ON processed_actions(created_at)")
260255
set_db_version(1)
@@ -315,8 +310,7 @@ def migrate_database():
315310
if current_version < 4:
316311
logger.info("Applying migration: Add wiki hash caching table (v3 -> v4)")
317312

318-
cursor.execute(
319-
"""
313+
cursor.execute("""
320314
CREATE TABLE IF NOT EXISTS wiki_hash_cache (
321315
id INTEGER PRIMARY KEY AUTOINCREMENT,
322316
subreddit TEXT NOT NULL,
@@ -325,8 +319,7 @@ def migrate_database():
325319
last_updated INTEGER DEFAULT (strftime('%s', 'now')),
326320
UNIQUE(subreddit, wiki_page)
327321
)
328-
"""
329-
)
322+
""")
330323
cursor.execute("CREATE INDEX IF NOT EXISTS idx_subreddit_page ON wiki_hash_cache(subreddit, wiki_page)")
331324
logger.info("Created wiki_hash_cache table")
332325

@@ -666,12 +659,10 @@ def update_missing_subreddits():
666659
cursor = conn.cursor()
667660

668661
# Get entries with NULL subreddit but valid permalink
669-
cursor.execute(
670-
"""
662+
cursor.execute("""
671663
SELECT id, target_permalink FROM processed_actions
672664
WHERE subreddit IS NULL AND target_permalink IS NOT NULL
673-
"""
674-
)
665+
""")
675666

676667
updates = []
677668
for row_id, permalink in cursor.fetchall():
@@ -751,9 +742,7 @@ def get_recent_actions_from_db(config: Dict[str, Any], force_all_actions: bool =
751742
SELECT COUNT(*) FROM processed_actions
752743
WHERE created_at >= ? AND action_type IN ({})
753744
AND LOWER(subreddit) = LOWER(?)
754-
""".format(
755-
placeholders
756-
),
745+
""".format(placeholders),
757746
[cutoff_timestamp] + list(wiki_actions) + [subreddit_name],
758747
)
759748

tests/test_removal_reasons.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Test script to verify removal reason processing without Reddit API calls
44
Creates a local markdown file to demonstrate the functionality
55
"""
6+
67
import os
78
import sqlite3
89
import sys
@@ -70,8 +71,7 @@ def test_removal_reasons():
7071
cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='processed_actions'")
7172
if not cursor.fetchone():
7273
print(" Database table not found, creating manually...")
73-
cursor.execute(
74-
"""
74+
cursor.execute("""
7575
CREATE TABLE processed_actions (
7676
id INTEGER PRIMARY KEY AUTOINCREMENT,
7777
action_id TEXT UNIQUE NOT NULL,
@@ -85,8 +85,7 @@ def test_removal_reasons():
8585
created_at INTEGER NOT NULL,
8686
processed_at INTEGER DEFAULT (strftime('%s', 'now'))
8787
)
88-
"""
89-
)
88+
""")
9089
conn.commit()
9190
conn.close()
9291

0 commit comments

Comments
 (0)