Skip to content

fix(python): correct shipment and smart_rate service names in examples - #232

Open
Sameer Kumar (sameerkumar18) wants to merge 1 commit into
masterfrom
fix-python-shipment-smartrate-service-names
Open

fix(python): correct shipment and smart_rate service names in examples#232
Sameer Kumar (sameerkumar18) wants to merge 1 commit into
masterfrom
fix-python-shipment-smartrate-service-names

Conversation

@sameerkumar18

@sameerkumar18 Sameer Kumar (sameerkumar18) commented Aug 24, 2026

Copy link
Copy Markdown
Member

Found while working DOCS-527 / #231. Same class of bug, different examples and different docs pages, so raised separately. No Jira ticket yet — happy to file one if you'd like it tracked.

The bugs

Two published Python examples reference client properties that do not exist on EasyPostClient, so they raise AttributeError when run as-is.

1. client.shipmentsclient.shipment

pagination/get-next-page.py#L11 — renders on docs.easypost.com/docs/pagination

The file was internally inconsistent — it already used the correct property two lines earlier:

shipments = client.shipment.all(page_size=5)              # correct
next_page = client.shipments.get_next_page(shipments)     # AttributeError

Note shipments is also a local variable here, so this needed a targeted fix rather than a rename.

2. client.smartrateclient.smart_rate

…-deliver-by.py#L5 and …-deliver-on.py#L5 — render on docs.easypost.com/docs/smartrate

results = client.smartrate.estimate_delivery_date(...)    # AttributeError
results = client.smartrate.recommend_ship_date(...)       # AttributeError

The service class is SmartRateService, defined in smartrate_service.py — the filename not matching the property is the likely source of the confusion.

Verification

Checked against easypost-python v10.7.0, the current PyPI release (confirmed via the PyPI JSON API; master and the v10.7.0 tag are identical here):

self.shipment   = ShipmentService(self)
self.smart_rate = SmartRateService(self)
  • No self.shipments or self.smartrate property exists in v8.2.1, v9.5.0, or v10.7.0.
  • The client defines no __getattr__, __getattribute__, setattr, or aliasing, so these are hard failures rather than tolerated spellings.
  • The methods were all correct — get_next_page exists on ShipmentService; estimate_delivery_date and recommend_ship_date on SmartRateService. Only the property names were wrong.
  • Independent cross-check: the Ruby examples already use client.shipment and client.smart_rate, matching Ruby's to_snake_case(ClassName) derivation.

Scope

7 occurrences across 7 files (current, v9, v8):

Property current v9 v8
shipmentsshipment 1 1 1
smartratesmart_rate 2 2

v8 has no smartrate deliver-by/on examples because those methods landed in v9.3.0 — that absence is correct, not a gap. self.shipment is present as far back as v8.2.1, so the v8 pagination fix is valid for its version.

Only current is rendered on the docs site (it imports python/current/ exclusively), so the v8/v9 files can be trimmed from this PR if you'd rather limit it to the rendered surface.

Result

I validated every client.<service> reference in official/docs/python/current/ against the live service list from EasyPostClient. Three properties were invalid; this PR fixes two and #231 fixes the third (api_keyapi_keys). Together the two PRs bring python/current/ to zero invalid service references.

Checks

  • python3 -m py_compile passes on all 7 files
  • Local shipments variable in the pagination example verified intact
  • Longest changed line is 52 chars, within line-length = 120 from style_guides/python/pyproject.toml (flake8 not run — not installed in my active env)
  • Zero client.shipments. / client.smartrate. occurrences remain under official/docs/python/

Two Python examples reference client properties that do not exist on
EasyPostClient, so they raise AttributeError when run as published:

- pagination/get-next-page.py used `client.shipments.get_next_page(...)`;
  the service is `self.shipment`. The same file already calls
  `client.shipment.all()` two lines earlier, so it was internally
  inconsistent.
- smartrate/retrieve-standalone-smartrate-deliver-{by,on}.py used
  `client.smartrate.*`; the service is `self.smart_rate`. The service
  class is `SmartRateService` (in smartrate_service.py), which is the
  likely source of the confusion.

Verified against easypost-python v10.7.0 (current PyPI release) and the
v8.2.1/v9.5.0 tags, so the v8 and v9 example directories are affected too.
The client defines no __getattr__ or aliases, so these are hard failures
rather than tolerated spellings.

The methods themselves were correct: `get_next_page` exists on
ShipmentService, and `estimate_delivery_date`/`recommend_ship_date` on
SmartRateService. Only the property names were wrong.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, these were renamed in the last couple versions but examples apparently never updated. Please verify there are no changes needed in the UPGRADE_GUIDE of the python lib to accompany these.

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