chore(zulip): remove dead code and fix mechanical hygiene smells
Opened by @niyazmft · Assignees: None
Solve & Merge Reward: Up to +210 XP & +60 Coins
+30 XP on PR open · +180 XP & +60 coins on merge
Claim Status & GitHub Signal
Unassigned with 0 comments. Open the workspace to inspect linked PRs before claiming or coding.
Estimated from issue labels (help wanted, good first issue), Python context, and discussion depth. No comments are posted yet, so check repository conventions carefully. Note: this is an estimate, not a guarantee.
What It's About
chore(zulip): remove dead code and fix mechanical hygiene smells. Summary Mechanical cleanup across five files. No behaviour change; each item is independent and can be reviewed as its own commit in one PR. Items 1. zulip/connection.py:296–297 — duplicated statement The same assignment is written twice, back to back. Delete
Why It Matters
Resolving #313 improves reliability and developer experience in niyazmft/zulip-hermes-integration.
Expected Outcome
A focused pull request addressing #313 with relevant checks or tests verified locally.
Log in to compare this issue's requirements against your profile skills. Required concepts: Python, Testing & pytest, HTTP & REST APIs, Git & Collaboration, CLI & Shell, Object-Oriented Design.
Progressive AI Hints
Hint #1 is always free and calibrated to your experience level. Extra hints unlock with coins without spoiling the full solution.
Skill-Gap Learning
Branching, commits, rebasing, and collaborative Git workflows.
Addresses skill gap: Git & Collaboration
Shell navigation, process inspection, pipes, and CLI debugging.
Addresses skill gap: CLI & Shell
Core Python syntax, functions, control flow, and debugging basics.
Addresses skill gap: Python
Issue Description
Summary
Mechanical cleanup across five files. No behaviour change; each item is independent and can be reviewed as its own commit in one PR.
Items
1. zulip/connection.py:296–297 — duplicated statement
bot_user_id = str(probe_result.get("bot", {}).get("id", ""))
bot_user_id = str(probe_result.get("bot", {}).get("id", ""))
The same assignment is written twice, back to back. Delete the second line.
2. zulip/updater.py — dead scaffolding + scattered imports
_GITHUB_PINNED_FINGERPRINTS: set[str] = set()(line 47) — empty, never read._verify_github_cert(...)(line 55) — defined, never called._PinnedHTTPSHandler(line 73) +urllib.request.install_opener(...)(lines 81–82) — installs a global opener that is no stricter than the default and runs at import time as a side effect. Delete the class and theinstall_openercall.- Duplicate imports:
from dataclasses import dataclassappears at line 22 and line 282;from typing import Optionalat line 24 and line 432. Consolidate to the top of the file.
Reference: the module's own docstring and tests/test_updater.py / tests/test_release_notes.py
cover the update path — confirm the suite still passes after removal.
3. zulip/audit_logger.py:59 — undefined type annotation
self._write_queue: asyncio_lock = None # type: ignore
asyncio_lock is not an imported name. Change the annotation to Optional[asyncio.Lock] and
import asyncio / Optional at the top. The # type: ignore goes away.
4. zulip/commands.py:24 and zulip/policy.py:21 — logger idiom
logger = __import__("logging").getLogger(__name__)
Every other module in the package uses:
import logging
logger = logging.getLogger(__name__)
Switch these two to match. No functional difference.
5. zulip/text_utils.py — dead code reachable only from tests
convert_markdown_tables(line 295) and_format_zulip_table(line 339) — no production caller._chunk_markdown_text(line 134) and theif mode == "markdown":branch inchunk_text(line 83) —resolve_chunk_config()inzulip/settings.pyonly ever produces"length"/"newline", so"markdown"mode is unreachable in production.
Remove these and their tests in tests/test_text_utils.py (the markdown-table tests and the
markdown-chunking tests). Note in the PR body that this is a deliberate dead-code removal; the
repo rule is "git history has it."
Acceptance
-
python3 -m pytest tests/test_updater.py tests/test_release_notes.py tests/test_text_utils.py -qgreen - Full suite green;
bash .githooks/pre-pushregenerateschecksums.txtwith no re-run diff -
rg -n "_verify_github_cert|_GITHUB_PINNED_FINGERPRINTS|_PinnedHTTPSHandler|install_opener|asyncio_lock|convert_markdown_tables|_format_zulip_table|_chunk_markdown_text" zulip/returns nothing
Reference
CONTRIBUTING.md§ "Rules That Bite" (esp. #3 checksums) and § "Commit Messages".
Linked Pull Requests (0)
No linked or cross-referenced pull requests detected via GitHub timeline. Check comments below for informal claims before starting.
GitHub Comments (0)
No comments on this issue yet.
Issue Troubleshooting Threads (0)
No troubleshooting threads opened for this issue yet. If you hit a test, build, or navigation blocker, post what you've tried so fellow contributors can help.
PR Verification & Rewards
Sign in and link GitHub to verify your PR against this issue and earn XP + coins.
Contribution Workflow
Track your local progress before opening a pull request on GitHub.
Repository Context
Top Repository Paths
CONTRIBUTING.md Excerpt
Contributing
Thanks for taking the time to contribute. This document covers development setup, the checks CI will run on your PR, and the handful of repo-specific rules that are easy to trip over.
Table of Contents
- Development Setup
- Project Layout
- Rules That Bite
- Testing
- Documentation Claims Are Tested
- Commit Messages
- Pull Request Process
- Release Process
Development Setup
-
Fork and clone:
git clone https://github.com/YOUR_USERNAME/zulip-hermes-integration.git cd zulip-hermes-integration -
Install dependencies (Python 3.10+; CI runs the suite on 3.12):
python3 -m pip install -r requirements.txt -
Install the pre-push hook:
bash scripts/setup-hooks.shThis points
core.hooksPathat.githooks. The hook regenerateschecksums.txtand runspy_compile, theplugin.yamlparse and the full test suite before any push, mirroring the fast CI job. To bypass it in an emergency, push with--no-verify(not recommended). -
Verify:
bash .githooks/pre-push
What CI runs, and how to run it yourself
| Local command | CI |
|---|---|
bash .githooks/pre-push | the fast zulip-bridge job: checksums.txt freshness, py_compile, plugin.yaml, pytest |
pip-audit -r requirements.txt | the fast job's dependency audit |
gitleaks dir . (or git .) | the fast job's secret scan; tuned by .gitleaks.toml |
python3 scripts/check_compat.py | the compat matrix legs — see Testing |
python3 scripts/parity_check.py | nothing — the parity workflow was removed (#229); this is manual |
The fast job is the required status check. It runs for documentation-only PRs too, because
the doc claims are tested. The compat matrix is shaped so
it can be a required check as well (issue #241): it always starts and always reports, and only
its work is skipped for docs-only changes, because a required check that is skipped at the
job level never reports and would leave such a PR permanently unmergeable.
Project Layout
zulip/ the plugin package — one module per concern
... (truncated)
Advisory PR Assistant
Helps structure your PR description or unpack reviewer feedback. Does not perform GitHub actions.