Drop 0.9-era date helper re-exports from the top-level webob package - #497
Merged
Conversation
parse_date, parse_date_delta, serialize_date, serialize_date_delta and timedelta_to_seconds moved to webob.datetime_utils in 0.9.7 (0196b09) and have been re-exported from webob for backwards compatibility ever since. They were never documented and never listed in webob.__all__. Import them from webob.datetime_utils instead. The UTC tzinfo object and the year/month/week/day/hour/minute/second timedelta constants are unaffected and remain importable from webob. Also add BaseRequest to webob.__all__. It was already importable from webob, but its absence from __all__ means type checkers reject "from webob import BaseRequest" once WebOb ships a py.typed marker, as proposed in #477. See #457
mmerickel
approved these changes
Aug 3, 2026
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.
Drops the five date helpers that the top-level
webobpackage has beenre-exporting for backwards compatibility since 0.9.7, and adds
BaseRequestto
webob.__all__.Background
parse_date,parse_date_delta,serialize_date,serialize_date_deltaandtimedelta_to_secondsoriginally lived inwebob/__init__.py. They moved towebob.datetime_utilsin 0196b09 (Nov 2009, version 0.9.7) and the importswere left behind in
__init__.pyfor compatibility. They were neverdocumented and never listed in
webob.__all__. Since 2.0 is a major, thisseems like the moment to let them go — they remain available from
webob.datetime_utils.The
UTCtzinfo object and theyear/month/week/day/hour/minute/secondtimedelta constants are unaffected and remain importable fromwebob; they're documented and used indocs/reference.txt.Why now
This came out of #457. Once #477 lands and WebOb ships a
py.typedmarker,names imported into
__init__.pybut absent from__all__stop beingre-exports as far as type checkers are concerned. Installing #477 into a clean
venv and checking a consumer that does
from webob import BaseRequest, parse_date:All six names fail the same way.
BaseRequestis genuinely public anddocumented, so it belongs in
__all__; the five date helpers are betterdropped than blessed. With this change applied on top of #477, that consumer
file is clean under both pyright and
mypy --strict.Note this wouldn't have been caught by #477's own CI:
mypy -p webobpassesclean there, because
no_implicit_reexportflags the importing module andnothing inside WebOb imports these from the top-level package. It only
surfaces for consumers, after release. A regression test belongs in the
tests/mypy/harness that #477 introduces, so I've suggested it there ratherthan adding a mypy dependency here.
Verification
from webob import parse_datenow raisesImportError;webob.datetime_utilsstill exposes all fivefrom webob import *still supports the documentedres.cache_expires(2*day+4*hour)example# noqa: F401See #457