chore(ci): add mypy + hypothesis property tests#16
Open
rezhajulio wants to merge 2 commits into
Open
Conversation
Add a second layer of bug-catching via static type analysis and property-based testing. The unit/integration suite catches the bugs we thought of; mypy + Hypothesis catch the ones we didn't. mypy - Add mypy 2.1.0 + ruff back to dev dependencies. - Pragmatic config in pyproject.toml: ignore_missing_imports, disable error codes that are noisy from PTB / SQLModel / Pydantic v2 (arg-type, attr-defined, index, union-attr, misc, return-value, call-arg). The team tightens module-by-module over time. - Fix the 2 real type errors caught (Literal annotation for logfire min_log_level; type:ignore for preload_admin_ids called with Application instead of Context). Add 1 type:ignore for the application.job_queue.run_once call in captcha_recovery. - Strict override for bot.tests.* (new test code must be typed). Hypothesis property tests - New tests/test_properties.py: 19 property tests on pure functions (format_threshold_display, format_hours_display, _format_person, _format_person_with_username, is_url_whitelisted). 200 examples per test by default. Shrinks failing cases automatically. - These would have caught the "User 12345" placeholder bug from the previous round (is_url_whitelisted property) and the format-threshold edge cases we never enumerated. CI - Use uv for both lint and test jobs (consistent with dev workflow). - Lint job now runs ruff + mypy on every push and PR. - Test job matrix unchanged (3.11-3.14).
e082020 to
d64a595
Compare
Bring the docs in line with the current state of the codebase. AGENTS.md - Add mypy + hypothesis commands to the Commands section. - Document the modular plugin system in the Structure tree (src/bot/plugins/builtin/* wrapping src/bot/handlers/*). - New "Modular Plugin System" subsection under Architecture Patterns covering the wrapper pattern, per-group runtime gating, and how to add a new plugin. - New "Captcha Profile Check" subsection documenting the DB-first / Telegram-unrestrict-last ordering and the failure semantics. - Add admin_cache.py, trust.py, test_properties.py to the structure/code map. Note the TrustedUser table (5th DB table). - Add "Where to Look (Plugin System)" table for the new layer. - Update Testing section: property-based tests, ~970 tests total, test-delta tracking advice. - Update CI/CD: mypy step + pragmatic error-code disables. - Notes: trust feature, reviews/ gitignore, captcha DB ordering. README.md - Add mypy and property-test commands to Testing section. - Update test count: 977+ total including 19 Hypothesis tests. - Add scripts/backfill_trusted_names.py to Project Structure. - Add the plugins/ tree and trust.py handler to Project Structure. - Architecture section: mention plugin manager, guard_plugin, and the trust admin commands. - New "Captcha Verification with Profile Check" subsection (user-facing) explaining the join → click → profile check → unrestrict flow. - Update Installation to use `uv sync --dev`.
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.
Add a second layer of bug-catching via static type analysis and property-based testing. The unit/integration suite catches the bugs we thought of; mypy + Hypothesis catch the ones we didn't.
mypy
Hypothesis property tests
CI