Skip to content

Conversation

luhn
Copy link
Contributor

@luhn luhn commented Aug 25, 2025

While working on #3791, I ran into an issue: The cache buster was diving into the guts of PackageOverrides, stymying my attempts to refactor that.

pathspec = f'{pkg_name}:{pkg_subpath}{subpath}'
overrides = registry.queryUtility(IPackageOverrides, name=pkg_name)
if overrides is not None:
resource_name = posixpath.join(pkg_subpath, subpath)
sources = overrides.filtered_sources(resource_name)
for source, filtered_path in sources:
rawspec = source.get_path(filtered_path)
if hasattr(source, 'pkg_name'):
rawspec = f'{source.pkg_name}:{rawspec}'
break

In particular, get_path and pkg_name should be considered private members PackageAssetSource/FSAssetSource, because they are undocumented and aren't directly tested.

This PR is an attempt to formalize those into a public, tested method called get_spec.

I also added get_spec to the IPackageOverrides interface. This seemed necessary, as if we want to call that method after querying for the utility, it should be in the interface.

This comes with some minor behavior changes as well: The original _bust_asset_path implementation did not check for file existence (it always took the first matching override source), whereas the new implementation does in order to match the behavior of overrides elsewhere.

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