Skip to content

Conversation

@ye-soling
Copy link

This PR fixes an issue where inspect(sort=False) did not preserve the
insertion order of instance attributes.

Previously, instance attributes were always displayed in alphabetical order
because dir(obj) returns a sorted list of attribute names. This behavior
ignored the sort=False option.

To fix this, when sort=False and the object has a __dict__, the instance
attribute insertion order is used instead of dir(obj).

A test was added to ensure the attribute order is preserved when sort=False.

@ye-soling
Copy link
Author

Hi! Thanks for reviewing this PR 🙂
This fixes the issue where inspect(sort=False) did not preserve
instance attribute order and includes a test for the fix.
Please let me know if any changes are needed.

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.

1 participant