Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(db)!: remove SourceObject.iter_virtual_sources from our API #1106

Merged
merged 1 commit into from Mar 9, 2023

Conversation

dairiki
Copy link
Contributor

@dairiki dairiki commented Feb 26, 2023

The SourceObject.iter_virtual_sources method was introduced in PR #118. It is called (only) in Database.track_record_dependency to identify virtual sources to declare dependencies upon.

I have searched the Lektor source, as well as all of the Lektor plugins I can find on PyPI and GitHub, and have only found one instance where iter_virtual_sources returns anything other than an empty set. That is VirtualSourceObject.iter_virtual_sources, which returns only a single virtual source: self.

(Here is a search, purportedly of all the public repositories on GitHub, for iter_virtual_sources.)

It doesn't seem to make any sense for a record to declare a virtual source object as a dependency. Generally, records depend on the data and datamodel files (the .lr and .ini files) that define their content and behavior. What would it mean for a record to depend on another record? (And even if that were allowed, why only allow records to depend on other virtual sources but not regular non-virtual sources?)

PR #118 introduced this API, but didn't use it. The PR introduced the Siblings virtual source object. But it doesn't get introduced to an artifact's dependencies by way of SourceObject.iter_virtual_sources. The Siblings virtual source object gets declared as a dependency of the current artifact when it is accessed in Page.get_siblings(). (This makes perfect sense: when a source object is accessed during the building of an artifact it gets added to the dependency list.)

Breaking Change

This is potentially a breaking change, despite the fact that I can find no code that uses this feature.

We could first deprecate the API — issuing a warning whenever iter_virtual_sources returns anything unexpected — before removing it altogether. But I highly suspect nobody is using this bit of API.

Issue(s) Resolved

Cleans out unused code. Removes confusing and not particularly useful API.

@dairiki dairiki added this to the 3.4 milestone Feb 28, 2023
BREAKING CHANGE: though a search of Lektor plugins on GitHub and PyPI
did not find any instance where a non-empty `iter_virtual_sources` was
defined
@dairiki dairiki force-pushed the refactor.iter_virtual_sources branch from 751730d to 371c543 Compare March 9, 2023 00:30
@dairiki dairiki merged commit 9c62500 into lektor:master Mar 9, 2023
@dairiki dairiki deleted the refactor.iter_virtual_sources branch March 9, 2023 00:58
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.

None yet

1 participant