Skip to content

Fix undefined names in serverside AppData and ExtendedDeviceInfo - #1178

Open
ZainnQureshii wants to merge 1 commit into
meta:mainfrom
ZainnQureshii:fix/serverside-missing-imports
Open

ZainnQureshii wants to merge 1 commit into
meta:mainfrom
ZainnQureshii:fix/serverside-missing-imports

Conversation

@ZainnQureshii

Copy link
Copy Markdown

Fixes #708

facebook_business/adobjects/serverside/app_data.py and extended_device_info.py call six.iteritems (in to_dict()) and pprint.pformat (in to_str(), used by __repr__) but import neither module, so:

  • AppData(..., extinfo=ExtendedDeviceInfo(...)).to_dict() raises NameError: name 'six' is not defined
  • repr(AppData(...)) and repr(ExtendedDeviceInfo(...)) raise NameError: name 'pprint' is not defined

This adds import pprint and import six to both files, the same two imports the other serverside classes already have (six is already in requirements.txt). While there I also fixed ExtendedDeviceInfo.__eq__ (extended_device_info.py:320), which checked isinstance(other, Event), a name this file never defines, so ExtendedDeviceInfo(...) == ExtendedDeviceInfo(...) raised NameError: name 'Event' is not defined; it now checks ExtendedDeviceInfo, like AppData.__eq__ checks AppData.

These classes look generated, so if they come from an internal template, the template may need the same two imports.

Test plan

A short script calling AppData.to_dict(), repr(AppData(...)), repr(ExtendedDeviceInfo(...)) and ExtendedDeviceInfo(...) == ExtendedDeviceInfo(...) on Python 3.12 with requirements.txt installed:

  • on main: each raises the NameError above
  • with this change: all succeed, and equality gives True for equal objects and False for different ones

I kept a test out since the change is two imports per file and one class name; I can add one to facebook_business/test/unit.py if you'd like it.

Prepared with AI assistance (Claude Code) and reviewed with GitHub Copilot.

🤖 Generated with Claude Code

AppData.to_dict() and ExtendedDeviceInfo.to_dict() use six.iteritems and
both classes' to_str() use pprint.pformat, but neither module was
imported, so to_dict() and repr() raised NameError. ExtendedDeviceInfo's
__eq__ also checked isinstance(other, Event), a name this file never
defines, so comparing two instances raised NameError too.

Fixes meta#708

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@meta-cla meta-cla Bot added the CLA Signed label Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing six import in app_data.py causes NameError

1 participant