Modernize codebase with type hints, linting, and Python 3.8+ support#13
Open
typpo wants to merge 1 commit into
Open
Modernize codebase with type hints, linting, and Python 3.8+ support#13typpo wants to merge 1 commit into
typpo wants to merge 1 commit into
Conversation
Bring the library up to date after a long gap: Packaging - Migrate pyproject.toml to PEP 621 [project] metadata with the poetry.core.masonry.api build backend and PEP 735 dependency groups. - Drop end-of-life Python 3.7; minimum is now Python 3.8. Add classifiers for 3.8 through 3.13. - Ship type hints plus a py.typed marker (PEP 561). Client code - Add a configurable request timeout (default 60s) so network calls no longer hang indefinitely. - Remove Python 2 compatibility shims, use isinstance checks and f-strings, import requests at module load, and add type annotations. - Derive the User-Agent version from installed package metadata. CI and tooling - Replace Travis with a GitHub Actions matrix (Python 3.8-3.13). - Replace autopep8 with ruff for linting and formatting. - Make the live-service test opt-in via QUICKCHART_NETWORK_TESTS so the default suite is deterministic and offline-friendly. Docs - Update README badges, version notes, timeout docs, and add a Development section. Add CHANGELOG.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LDLZoKFv4Y4Q6rFYMn4MoL
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.
This PR modernizes the quickchart-python codebase with comprehensive type hints, updated tooling, and improved code quality standards.
Summary
The codebase has been updated to use modern Python practices including inline type hints (PEP 561), ruff for linting and formatting, and a modernized project configuration. Support for Python 3.7 has been dropped in favor of Python 3.8+.
Key Changes
Type Hints & Code Quality:
quickchart/__init__.pyusingtypingmodulepy.typedmarker file for PEP 561 complianceConfiguration & Packaging:
pyproject.tomlfrom Poetry-only format to PEP 621[project]metadatapoetry.core.masonry.apiTooling & CI/CD:
.github/workflows/ci.yml)autopep8withrufffor linting and formattingscripts/format.shto use ruff instead of autopep8ruffconfiguration with appropriate rules and per-file ignoresFeatures:
timeoutparameter (default 60 seconds) to network requestsUser-Agentversion from installed package metadata viaimportlib.metadata_serialized_config()helper method to reduce code duplicationTesting:
QUICKCHART_NETWORK_TESTSenvironment variableDocumentation:
CHANGELOG.mddocumenting changes in v2.1.0README.mdwith Python version requirements and development instructionsCode Formatting:
.gitignoreto include.pytest_cache/and.ruff_cache/Notable Implementation Details
timeoutparameter defaults to 60 seconds and applies to all network requests (get_bytes(),get_short_url(),to_file())OptionalandUnionfromtypingmodule rather than PEP 604 syntax (X | Y) to maintain Python 3.8 compatibilityhttps://claude.ai/code/session_01LDLZoKFv4Y4Q6rFYMn4MoL