Fix crash in states CLI when printing counties#102
Open
arpitjain099 wants to merge 1 commit into
Open
Conversation
The counties attribute added in 4.0.0 is a list of County objects, but the CLI's attribute loop tries to ", ".join() every list value, which raises a TypeError on the County objects. This crashed `states <state>` for every state. Show the county count instead and add a regression test. Signed-off-by: Arpit Jain <arpitjain099@gmail.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.
The `counties` attribute added in 4.0.0 is a list of `County` objects, but the CLI's "other attributes" loop still tries to `", ".join()` any list value. Joining the County objects raises `TypeError: sequence item 0: expected str instance, County found`, so running `states ` crashes for every state (it dies right after printing the scalar attributes).
This special-cases counties to print a count instead, which avoids dumping hundreds of county names inline and keeps the existing join path for the string-valued lists like `time_zones`. I added a small regression test that runs the CLI and checks it completes; it fails on main and passes with the change. Thanks for the recent 4.0.0 work on this library.