Skip to content

Sync instance-class-static-methods with the updated tutorial - #837

Open
realpython-bot wants to merge 1 commit into
masterfrom
maintenance/instance-class-static-methods-20260916
Open

realpython-bot wants to merge 1 commit into
masterfrom
maintenance/instance-class-static-methods-20260916

Conversation

@realpython-bot

Copy link
Copy Markdown
Collaborator

Companion-code sync for Python's Instance, Class, and Static Methods Demystified after this maintenance cycle.

What changed

pizza.py — the Pizza.get_size_in_inches() static method had drifted from the tutorial's listing:

  • Docstring restored to the article's wording: """Returns the diameter in inches for common pizza sizes.""" (the folder said "an approximate diameter in inches for common sizes").
  • size_map re-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.py already carried the colon on def static_method():, so this cycle's code-failure fix was article-only — no repo change needed.
  • The version-bump from python==3.13 to python==3.14 touches no file here: the folder is pure standard library, so there is no requirements.txt or constraints.txt for a reader to install from and nothing to re-pin.
  • The {% ref %} glossary links added this cycle are prose-only.
  • The two LOW pedagogical findings (the "enforced by the Python runtime" wording and raising instead of returning "Unknown size") were left for a human, so get_size_in_inches() keeps its sentinel return.

How this was verified

  • Fresh uv venv --python 3.14 (CPython 3.14.6), matching the draft's dependencies: python==3.14. No third-party packages are required.
  • demo.py and pizza.py both executed (MPLBACKEND=Agg) — both run clean.
  • Every code block and REPL session in the updated draft was replayed against these modules: all 22 expected outputs reproduce verbatim, including <demo.DemoClass object at 0x...>, <class 'demo.DemoClass'>, the TypeError: DemoClass.instance_method() missing 1 required positional argument: 'self' message, the Pizza([...]) reprs, the factory methods, and get_size_in_inches() returning 12, 8, and 16.
  • Repo gates at the version pinned in the root 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.

…hon's Instance, Class, and Static Methods Demystified

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

1 participant