Skip to content

Sync new materials folders with article bug fixes - #896

Merged
martin-martin merged 1 commit into
masterfrom
materials/sync-article-fixes-20261019
Oct 19, 2026
Merged

martin-martin merged 1 commit into
masterfrom
materials/sync-article-fixes-20261019

Conversation

@realpython-bot

Copy link
Copy Markdown
Collaborator

Follow-up to #895, which was merged before this commit reached it.

While building the folders in #895, the tutorials' own code turned out to have bugs. Those were fixed in the update drafts, and this PR brings the materials code in line with the fixed articles:

  • operator-function-overloading/custom_complex.py: the solution uses self.__class__ (matching the tutorial's snippets), returns NotImplemented for unsupported operands instead of failing with UnboundLocalError, uses atan2() in argz() (no ZeroDivisionError for a zero real part, correct quadrant for a negative one), and __eq__/__ne__ handle unrelated types; docstring typos fixed.
  • python-data-classes/position_make_dataclass.py: make_dataclass() field order now matches the class it's meant to be equivalent to (name, lon, lat).
  • documenting-python-code/: the spreadsheet script now reads .csv files as its docstring promises, keeps its docstring's formatting in the -h usage message, and names openpyxl/xlrd; typo fixes.
  • python-sql-libraries/: single-quoted SQL string literals (the PostgreSQL update crashed with double quotes), the PostgreSQL helpers catch psycopg2.Error so a rerun doesn't crash on DuplicateDatabase, and the missing comma between the FOREIGN KEY clauses.

Verified on Python 3.14 (SQL scripts against SQLite, MariaDB 10.11, and PostgreSQL 16); ruff 0.14.1 format/check and dircheck pass.

🤖 Generated with Claude Code

Keeps the code in sync with fixes applied to the update drafts:
- operator-function-overloading: CustomComplex uses self.__class__,
  returns NotImplemented for unsupported operands, uses atan2 in argz()
- python-data-classes: make_dataclass field order matches the class
- documenting-python-code: spreadsheet script reads CSV as documented,
  keeps its usage message formatting, typo fixes
- python-sql-libraries: single-quoted SQL literals, catch
  psycopg2.Error in the PostgreSQL helpers, comma between foreign keys

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@martin-martin
martin-martin merged commit f70f4ab into master Oct 19, 2026
1 check passed
@martin-martin
martin-martin deleted the materials/sync-article-fixes-20261019 branch October 19, 2026 17:45
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.

2 participants