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

chore: autoformat sparql-files with pre-commit #327

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

danhje
Copy link
Member

@danhje danhje commented Jan 8, 2025

No description provided.

@danhje danhje requested review from davidkleiven and leifwar January 8, 2025 14:54
@danhje danhje marked this pull request as draft January 8, 2025 15:22
@danhje danhje force-pushed the autoformat branch 3 times, most recently from e67f5ba to b71b0ea Compare January 9, 2025 12:00
Comment on lines -3 to +17
insert {graph ${g} {?s cim:IdentifiedObject.mRID ?mrid}}
where {
graph ${g} {?s a ${rdf_type}}
filter (not exists {?s cim:IdentifiedObject.mRID ?mrid})
bind(str(?s) as ?mrid)

INSERT {
GRAPH ?g {
?s cim:IdentifiedObject.mRID ?mrid .
}
}
WHERE {
GRAPH ?g {
?s a ?rdf_type .
}
FILTER NOT EXISTS {
?s cim:IdentifiedObject.mRID ?mrid .
}
BIND (str(?s) AS ?mrid)
Copy link
Member Author

@danhje danhje Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I struggled a bit with the substitutions ${g} and ${rdf_type} here. They trip up the formatter. Temporarily replacing them with placeholder strings, and putting the substitutions back after formatting, caused other issues. So I've removed them. But I haven't made the corresponding changes in the code yet. Are the substitutions necessary?

@danhje
Copy link
Member Author

danhje commented Jan 9, 2025

I unfortunately couldn't find a pip-installable CLI that actually works, this npm package is the only relatively bug-free formatter I could find.

The substitutions are causing some issues, hence the script that temporarily replaces them. If we remove the substitutions we don't need the script.

Comment on lines -42 to +49
filter(?analysis_enabled)
filter(?connected)
FILTER (?analysis_enabled = true)
FILTER (?connected = true)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the formatter finds a FILTER call with just a bool variable as argument, it removes the parenthesis. Run it again, and it complains about the missing parenthesis ... I think that's a bug, and will file an issue. In the meantime, I'm explicitly comparing against true to avoid the issue.

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