Skip to content

近代的な Python 3 へのリファクタリングと CI/ツール刷新 - #117

Open
takano32 wants to merge 1 commit into
masterfrom
modernize-python3-idioms
Open

近代的な Python 3 へのリファクタリングと CI/ツール刷新#117
takano32 wants to merge 1 commit into
masterfrom
modernize-python3-idioms

Conversation

@takano32

@takano32 takano32 commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

概要

挙動を変えない範囲で、コードを近代的な Python 3 のイディオムに整理し、周辺ツールも刷新しました。

コード変更

種別 内容
型判定 type(x) is Tisinstance(x, T)
文字列 % / + 連結 → f-string
クリーンアップ 不要な # -*- coding: utf-8 -*- ヘッダ・(object) 基底クラスを削除
真偽値 is True / is False / is not True を素直な評価に
リソース open()with 文に、bare except:except Exception:
dead code HTMLParserunescape ハンドラを削除(convert_charrefs=True のため呼ばれず、かつ Py3.9 で unescape は削除済み)

バグ修正

  • subculture/redis.py: e.message(Python 3 では AttributeError)を str(e) に修正
  • SelfUpdateSubculture: os.system("make update_packages")subprocess.run([...]) に置換(シェル経由を排除)

ツール刷新

  • CI: Python 2.7 の Travis を廃止し、GitHub Actions(Python 3.12 + redis サービス + mecab)に置換
  • Makefile: setupvirtualenv から標準ライブラリの python3 -m venv
  • requirements.txt: Py3 標準ライブラリの ipaddress を削除
  • README / .gitignore: 現行手順・生成物に合わせて更新

検証

  • 全ソースの py_compile を確認
  • METAR / DogeDetailStatus の出力フォーマット等価性を個別に確認
  • 完全なテストスイート(redis / mecab が必要)は本 PR で追加した GitHub Actions 上で実行されます

🤖 Generated with Claude Code

コードの挙動を変えない範囲で近代化したリファクタリング。

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
yuiseki self-requested a review June 29, 2026 00:18

@yuiseki yuiseki left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI で Lint が落ちている模様です。 Lint ルールを実装に揃えるなどの対応していただけるとありがたいです 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants