Skip to content

Keep request futures local to sherlock#2946

Open
jameswjr wants to merge 1 commit into
sherlock-project:masterfrom
jameswjr:keep-request-futures-local
Open

Keep request futures local to sherlock#2946
jameswjr wants to merge 1 commit into
sherlock-project:masterfrom
jameswjr:keep-request-futures-local

Conversation

@jameswjr
Copy link
Copy Markdown

@jameswjr jameswjr commented May 7, 2026

Summary

This keeps request futures local to sherlock() instead of storing them inside the caller-provided site_data dictionaries.

Rationale

Although Sherlock is primarily used as a CLI, sherlock() is an importable function and is already called directly in the test suite. A wrapper, integration, or downstream test can reasonably pass in
a site_data object and expect it to remain site metadata rather than become temporary request-state storage.

Currently, the function iterates through site_data like this:

for social_network, net_info in site_data.items():

Inside that loop, net_info is the per-site dictionary from site_data. The current implementation stores runtime request state there:

net_info["request_future"] = future

and reads it back later.

This is harmless in the normal one-shot CLI path, because the mutated site_data is usually discarded. But it can surprise callers that reuse, inspect, compare, serialize, or share the same site_data
object.

This PR preserves the existing two-pass flow, but stores futures in a local dictionary keyed by social-network name instead.

Behavior

This should preserve user-visible behavior. It changes only where temporary request futures are stored during the call.

The invalid-username path is still handled: when no future is created, the site already has a status, and the second pass continues before reading from the local futures dictionary.

Test

Added a focused no-network regression test that fakes the futures session and asserts that sherlock() does not mutate the supplied site_data.

Local validation

python3 -m py_compile sherlock_project/sherlock.py tests/test_ux.py

I prepared this outside a fully installed Sherlock development environment, so I was not able to run the focused pytest command locally. The intended focused test command is:

python -m pytest -q tests/test_ux.py::test_sherlock_does_not_mutate_input_site_data

@jameswjr jameswjr requested a review from ppfeister as a code owner May 7, 2026 22:32
@ppfeister ppfeister added the enhancement New feature or request label May 8, 2026
@ppfeister ppfeister self-assigned this May 8, 2026
@ppfeister
Copy link
Copy Markdown
Member

Disregard the docker build failure, that's unrelated to your PR.
Will take a look shortly. Might be a good change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants