fix(model): stop using removed peewee.basestring in Model._validate - #69
Open
hello-wn wants to merge 6 commits into
Open
fix(model): stop using removed peewee.basestring in Model._validate#69hello-wn wants to merge 6 commits into
hello-wn wants to merge 6 commits into
Conversation
peewee>=4 dropped the py2-compat `basestring` alias, so `save(only=[...])` raised AttributeError on any environment with peewee 4 installed since Model._validate() checked `isinstance(field, pw.basestring)`. Use the builtin str instead, which is correct for both peewee 3.x and 4.x given peeweext already requires python_requires='>=3'. Adds a regression test that simulates a peewee>=4 environment (no peewee.basestring) without touching peewee's own internals. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
The repo currently has no CI that actually runs the test suite (.github/workflows only covers PyPI publish on release and stale-issue triage; the legacy .travis.yml required check is no longer reported by any active integration). Add a workflow that spins up MySQL and Postgres services and runs `pytest tests` on both sides of the peewee 3/4 compatibility line this branch fixes. Co-Authored-By: Claude <noreply@anthropic.com>
pip's resolver was backtracking into sea==3.1.5's old, source-only grpcio<1.49.0 pin, which fails to build on modern Python/setuptools (setuptools dropped pkg_resources, which grpcio's legacy setup.py still imports). sea>=4.0.0 pulls grpcio<1.69.0,>=1.49.0, which has prebuilt wheels. Verified tests/test_sea.py passes locally against sea==4.0.0. Co-Authored-By: Claude <noreply@anthropic.com>
…ance dependents Model.dependencies(search_nullable) controls which dependent rows peewee even discovers, not just how they get handled. delete_instance() was passing delete_nullable (False by default) as search_nullable, so a nullable FK dependent was never discovered at all, never got nulled out, and the parent delete then failed with a foreign key constraint error. Reproduced against real MySQL 8; the existing test_instance_delete::delete_instance(recursive=True) case now passes. Also fix URLValidator: Python 3.9+'s urlsplit() raises ValueError itself for malformed bracketed IPv6 hosts (e.g. "[::1:2::3]") instead of letting our own ipaddress.IPv6Address check catch it, so that call needs the same try/except ValueError guard already used elsewhere in this validator. Both were long-standing bugs invisible until the new CI workflow (added earlier in this branch) actually ran the suite against real MySQL and Python 3.11 for the first time. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <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.
Summary
peewee>=4dropped the py2-compatbasestringalias (peewee.basestring).Model._validate()inpeeweext/model.pyusedisinstance(field, pw.basestring)when handlingsave(only=[...]), which raisesAttributeError: module 'peewee' has no attribute 'basestring'on any environment resolving to peewee 4.x — sincerequirements.txtdoesn't cap thepeeweeversion, a plainpip installcan pick up peewee 4 today.BACKEND-EXAM-21H2): a cache-hit path calledtask.save(only=[...])and crashed, so the business side never got notified.pw.basestringwith the builtinstr— correct for both peewee 3.x and 4.x, and peeweext already requirespython_requires='>=3'so no py2 compat is needed.Test plan
tests/test_model.py::test_save_only_without_peewee_basestring, which patches thepwname insidepeeweext.modelwith a proxy that raisesAttributeErrorforbasestring(simulating peewee>=4) without touching peewee's own internals (which still referencebasestringelsewhere on 3.x), then callssave(only=[...])with both a field-name string and aFieldobject.AttributeError; with the fix it passes.peewee==4.3.0installed against pre-fix code, confirming the traceback matches the Sentry report; confirmed the fix resolves it in the same venv.test_datetime,test_json_field_mysql, Postgres-backed tests, etc.) since this environment has no MySQL/Postgres/Docker available — those are pre-existing environment requirements, unrelated to this change.🤖 Generated with Claude Code