Conversation
コードの挙動を変えない範囲で近代化したリファクタリング。
Code:
- isinstance(x, T) に統一(type(x) is T を廃止)
- f-string 化(%, + 連結を置換)
- 不要な `# -*- coding: utf-8 -*-` ヘッダと `(object)` 基底を削除
- `is True` / `is False` / `is not True` を真偽値の素直な評価に
- open() を with 文に、bare except を except Exception に
- HTMLParser の dead code(convert_charrefs で呼ばれない unescape ハンドラ)を削除
- バグ修正: redis.py の `e.message`(Py3 で AttributeError)を str(e) に
- os.system("make update_packages") を subprocess.run に置換
Tooling:
- Travis (Python 2.7) を GitHub Actions (Python 3.12 + redis + mecab) に置換
- Makefile setup を virtualenv から `python3 -m venv` に
- requirements.txt から不要な ipaddress(Py3 標準) を削除
- README を更新(GH Actions バッジ / 現行セットアップ手順)
- .gitignore に venv/pytest 生成物を追加
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
yuiseki
self-requested a review
June 29, 2026 00:18
yuiseki
requested changes
Jun 29, 2026
yuiseki
left a comment
Collaborator
There was a problem hiding this comment.
CI で Lint が落ちている模様です。 Lint ルールを実装に揃えるなどの対応していただけるとありがたいです 🙏
- Remove genuinely unused imports (math, Subculture, KnowerLevelUpSubculture, TwitterScraperSubculture in sun.py; HitozumaSubculture in tests.py) - Declare __all__ in subculture/__init__.py so flake8 recognizes the package-level imports as intentional re-exports (F401) - Fix style issues: E302, E265, E122, E713, E741, W293, W503 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Delete subculture/{doge,knower,media,retirement}.py, which consisted
solely of re-imports from subculture.redis, and drop the leftover
re-imports at the top of linguistic.py and misc.py. Nothing in this
repository references these module paths; everything goes through the
subculture package root. Revert this commit if any external script
still imports the old paths.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
divide_wordclass and the backward/break dictionaries in SilentSubculture assume ipadic's 9-field feature format, but mecab-python3 silently picks unidic when the unidic package is installed, so every feature lookup missed and SilentSubculture always returned None in CI. Pass ipadic.MECAB_ARGS to every Tagger and swap the unidic dependency (and its download step in CI/Docker/Makefile) for the pip ipadic package. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
get_element_title decoded content as UTF-8 regardless of the content_encoding that fetch(guess_encoding=True) detected, so Shift-JIS and EUC-JP pages raised UnicodeDecodeError. Decode with the detected encoding (errors='replace') instead. Also refresh the network-dependent tests: the FreeBSD handbook now redirects to the documentation portal with a longer title, and the gizmodo/reuters/instagram/google-photos fixtures are dead links or behind a login, so comment those out like the other retired tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The redis connection uses decode_responses=True, which makes GET raise UnicodeDecodeError on the binary pickle payloads Gaishutsu was storing, so the 既出 check has been dead under Python 3. Store JSON instead, and treat undecodable or unparsable legacy entries as unseen so they get overwritten in the new format on first touch. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
nomenclator.la.coocan.jp is not reachable from GitHub Actions runners, so the test always saw an empty response in CI. Serve an equivalent Shift-JIS page from a local HTTP server instead, which keeps the encoding-detection regression coverage deterministic. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Slack/Lingr payloads can carry "text": null, and the 'text' in n['message'] guard only checks key presence, so pattern.search(None) raised TypeError: expected string or bytes-like object. Check the value with isinstance instead and add a regression test. Closes #111 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Collaborator
Author
|
@yuiseki レビューありがとうございます。ご指摘の Lint は、ルールを実装に揃える形で対応しました(本当に未使用の import は削除、 あわせて、Lint が通ったことで表面化した既存のテスト失敗も一通り修正し、CI は green になっています(MeCab の辞書を ipadic に明示、TitleExtract の文字コード decode 修正、Gaishutsu の pickle→JSON 化、死んだ外部 URL テストの整理など。詳細は description に追記済みです)。#112 と #111 もこの PR で閉じる想定です。 お手すきの際に再レビューをお願いします 🙏 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
挙動を変えない範囲で、コードを近代的な Python 3 のイディオムに整理し、周辺ツールも刷新しました。
コード変更
type(x) is T→isinstance(x, T)%/+連結 → f-string# -*- coding: utf-8 -*-ヘッダ・(object)基底クラスを削除is True/is False/is not Trueを素直な評価にopen()をwith文に、bare except:→except Exception:HTMLParserのunescapeハンドラを削除(convert_charrefs=Trueのため呼ばれず、かつ Py3.9 でunescapeは削除済み)バグ修正
subculture/redis.py:e.message(Python 3 ではAttributeError)をstr(e)に修正SelfUpdateSubculture:os.system("make update_packages")をsubprocess.run([...])に置換(シェル経由を排除)ツール刷新
setupをvirtualenvから標準ライブラリのpython3 -m venvにipaddressを削除レビュー対応(追記)
Lint 指摘への対応と、CI が動くようになったことで表面化した既存の問題の修正を追加しました。
subculture/__init__.pyには__all__を定義して再エクスポートを明示。スタイル違反(E302/E265/E122/E713/E741/W293/W503)も修正subculture/{doge,knower,media,retirement}.pyとlinguistic.py/misc.pyの再インポート行を削除。リポジトリ内に参照はありません(外部スクリプトが旧パスを import している場合は f2b26d7 を revert してください)MeCab.Tagger(ipadic.MECAB_ARGS)を明示し、依存を unidic → ipadic(pip 版)に変更guess_encodingで判定したcontent_encodingを無視して UTF-8 決め打ちで decode していたバグを修正(Shift-JIS / EUC-JP ページでUnicodeDecodeErrorになっていた)decode_responses=Trueの接続に binary pickle を保存していたため GET 時にUnicodeDecodeErrorが発生していた問題を修正。Redis に残っている旧 pickle エントリは初回アクセス時に新形式で上書きされます(自己修復)"text": nullイベントで TypeError になる問題を修正:'text' in n['message']はキーの存在しか見ていないためpattern.search(None)に到達していた。値をisinstance(..., str)で確認するよう変更し、回帰テストを追加Closes #112
Closes #111
検証
py_compileを確認🤖 Generated with Claude Code