Repository navigation
Fix issues found during the connection-reuse review - #36
Merged
Merged
Conversation
bulk() accepts a set of resources in its validation, but the set was handed to the JSON encoder as-is, which cannot serialise it, so every call with a set failed with "Object of type set is not JSON serializable" wrapped in an IPDataException. The resources are now sent as a list. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
DotDict.__getattr__ wrapped every element of a list value in a DotDict, so reading an attribute whose value is a list of scalars, for example [1, 2, 3], raised TypeError. Only dict elements are wrapped now and the other elements are returned unchanged. Lists of objects such as threat.blocklists behave as before. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
"ipdata batch -e <field>" raised UnboundLocalError because the excluded fields were subtracted from ipdata.valid_fields before the ipdata client was assigned in the same function. The class attribute is used instead, and the remaining fields are sorted so that CSV columns always come out in the same order. The check that CSV output needs a field list now runs after --exclude has been turned into one, so "--format CSV --exclude <field>" works as well. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The list of threat members that the batch command expands into CSV columns did not include is_vpn or scores, so threat_is_vpn and threat_scores were silently dropped from CSV rows while the JSON output had them. Both columns are written now, in the position the API returns them. The blocklist dates need no column of their own: they are part of each entry in the threat_blocklists column. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The example used --output-format, which the batch command does not have; the option is --format. The sentence after it now also names --exclude as the alternative to --fields for CSV output. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
test_bulk_v4 and test_bulk_v6 compared each requested IP with itself, so they never checked the addresses the API returned. They now check that the returned addresses are exactly the requested ones, compared case-insensitively for IPv6. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…o Python 3.13 actions/checkout@v4 and actions/setup-python@v5 run on Node 20, which GitHub has deprecated on its runners; both move to their current major versions, which run on Node 24. Python 3.14 joins the test matrix and the classifiers. The publish job no longer pins the 2022 patch release 3.10.4; it uses 3.13, a version the test matrix covers, and installs build without --user. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.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.
Summary
Fixes the items recorded under "Noticed, not changed" in #35:
bulk()given a set,DotDictdot access to a list of scalars, the CLIbatch --excludecrash, missingthreatcolumns in the batch CSV output, a wrong flag in the README batch example, two live tests that compared a value with itself, and the CI workflow's Node 20 actions and 2022 Python pin. No version number changes and no breaking changes to the public API.Changes
bulk()accepts asetof resources: the resources are sent as a JSON list, so a set no longer fails withIPDataException("... Object of type set is not JSON serializable"). (ac32091)DotDict: dot access to a list of scalars (data.xwhenx == [1, 2, 3]) returns the list instead of raisingTypeError; only dict elements are wrapped, sodata.threat.blocklists[0].nameworks as before. (7ce7d14)ipdata batch -e <field>works instead of raisingUnboundLocalError; the remaining fields are requested in sorted order so that CSV columns are stable, and--format CSV --exclude <field>is accepted (CSV output needs either--fieldsor--exclude). (017c61e)threat_is_vpnandthreat_scorescolumns, which were dropped from the rows before; the blocklist dates are part of each entry in the existingthreat_blocklistscolumn. (3504289)--format CSV(the command has no--output-formatoption) and the text names--excludeas the alternative to--fields. (924985c)test_bulk_v4andtest_bulk_v6compare the returned IPs with the requested ones (case-insensitively for IPv6) instead of comparing each requested IP with itself. (9d42f29)actions/checkout@v7andactions/setup-python@v7(Node 24) replace the Node 20@v4and@v5; Python 3.14 joins the test matrix and the classifiers; the publish job uses Python3.13instead of the pinned3.10.4and installsbuildwithout--user. Its steps, tag gate and runner image are otherwise unchanged. (07ec54d)Not changed
timeoutforlookup()/bulk(): a new feature rather than a defect; the constructortimeoutapplies to every request, bulk lookups included.Verification
python -m pytest -m "not api"(Python 3.13.18, package installed in editable mode,requestsnot installed):94 passed, 4 deselected(87 passed, 4 deselectedonmaster; the 7 new tests cover each behaviour change). The single warning is aDeprecationWarningraised byclick_default_groupwhen the CLI module is imported and predates this branch.requirements.txt, package not installed):94 passed, 4 deselectedeach.python -m pytest -m api --collect-only: the four live tests still collect. They are not run here (they needIPDATA_API_KEYand run on pushes tomaster).ast.parse(source, feature_version=(3, 9))on every changed module: OK. The workflow parses as YAML with the expected matrix, action versions and publish Python version.07ec54d(pull_requestevent): success.Test (Python 3.9),3.10,3.11,3.12,3.13and3.14all passedpython -m pytest -m "not api"onubuntu-24.04withactions/checkout@v7andactions/setup-python@v7;Build and publish to PyPIwas skipped on the pull request, as intended.🤖 Generated with Claude Code