Sync instance-class-static-methods with the updated tutorial - #837
Open
realpython-bot wants to merge 1 commit into
Open
realpython-bot wants to merge 1 commit into
realpython-bot wants to merge 1 commit into
Conversation
…hon's Instance, Class, and Static Methods Demystified Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Companion-code sync for Python's Instance, Class, and Static Methods Demystified after this maintenance cycle.
What changed
pizza.py— thePizza.get_size_in_inches()static method had drifted from the tutorial's listing:"""Returns the diameter in inches for common pizza sizes."""(the folder said "an approximate diameter in inches for common sizes").size_mapre-expanded to the article's one-key-per-line literal with a trailing comma, instead of the collapsed one-liner.What deliberately did not change
demo.pyalready carried the colon ondef static_method():, so this cycle'scode-failurefix was article-only — no repo change needed.version-bumpfrompython==3.13topython==3.14touches no file here: the folder is pure standard library, so there is norequirements.txtorconstraints.txtfor a reader to install from and nothing to re-pin.{% ref %}glossary links added this cycle are prose-only.pedagogicalfindings (the "enforced by the Python runtime" wording and raising instead of returning"Unknown size") were left for a human, soget_size_in_inches()keeps its sentinel return.How this was verified
uv venv --python 3.14(CPython 3.14.6), matching the draft'sdependencies: python==3.14. No third-party packages are required.demo.pyandpizza.pyboth executed (MPLBACKEND=Agg) — both run clean.<demo.DemoClass object at 0x...>,<class 'demo.DemoClass'>, theTypeError: DemoClass.instance_method() missing 1 required positional argument: 'self'message, thePizza([...])reprs, the factory methods, andget_size_in_inches()returning12,8, and16.requirements.txt(ruff==0.14.1):uvx ruff@0.14.1 format --check instance-class-static-methods→ "2 files already formatted";uvx ruff@0.14.1 check instance-class-static-methods→ "All checks passed!".Needs a human merge.