Skip to content

Commit

Permalink
Minor formatting for docstring check and docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtavis committed Oct 26, 2024
1 parent 9cb19e4 commit 60755bd
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 25 deletions.
25 changes: 14 additions & 11 deletions src/scribe_data/check/check_query_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ def check_forms_order(query_text: str) -> bool:
return select_vars == where_vars


# MARK: docstring Format
# MARK: Docstring Format


def check_docstring(query_text: str) -> bool:
Expand All @@ -502,16 +502,16 @@ def check_docstring(query_text: str) -> bool:
Parameters
----------
query_text : str
The SPARQL query's text to be checked.
query_text : str
The SPARQL query's text to be checked.
Returns
-------
bool
True if the docstring is correctly formatted; otherwise, .
bool
True if the docstring is correctly formatted.
"""
# Split the text into lines.
lines = query_text.splitlines(keepends=True)
query_lines = query_text.splitlines(keepends=True)

# Regex patterns for each line in the docstring and corresponding error messages.
patterns = [
Expand All @@ -525,11 +525,14 @@ def check_docstring(query_text: str) -> bool:
"Error in line 3:",
),
]
# Check each line against its corresponding pattern.
for i, (pattern, error_line_number) in enumerate(patterns):
if not re.match(pattern, lines[i]):
return (False, f"{error_line_number} {lines[i].strip()}")
return True
return next(
(
(False, f"{error_line_number} {query_lines[i].strip()}")
for i, (pattern, error_line_number) in enumerate(patterns)
if not re.match(pattern, query_lines[i])
),
True,
)


# MARK: Main Query Forms Validation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# tool: scribe-data
# All Hindi (Q11051) adjectives (Q34698) and the given forms.
# All Hindi Hindustani (Q11051) adjectives (Q34698) and the given forms.
# Enter this query at https://query.wikidata.org/.

# Note: We need to filter for "hi" to remove Urdu (ur) words.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# tool: scribe-data
# All Hindi (Q11051) adverbs (Q380057) and the given forms.
# All Hindi Hindustani (Q11051) adverbs (Q380057) and the given forms.
# Enter this query at https://query.wikidata.org/.

# Note: We need to filter for "hi" to remove Urdu (ur) words.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# tool: scribe-data
# All Hindi (Q11051) nouns (Q1084) and the given forms.
# All Hindi Hindustani (Q11051) nouns (Q1084) and the given forms.
# Enter this query at https://query.wikidata.org/.

# Note: We need to filter for "hi" to remove Urdu (ur) words.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# tool: scribe-data
# All Hindi (Q11051) postpositions (Q161873) and the given forms.
# All Hindi Hindustani (Q11051) postpositions (Q161873) and the given forms.
# Enter this query at https://query.wikidata.org/.

# Note: We need to filter for "hi" to remove Urdu (ur) words.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# tool: scribe-data
# All Hindi (Q11051) prepositions (Q4833830) and the given forms.
# All Hindi Hindustani (Q11051) prepositions (Q4833830) and the given forms.
# Enter this query at https://query.wikidata.org/.

# Note: We need to filter for "hi" to remove Urdu (ur) words.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# tool: scribe-data
# All Hindi (Q11051) proper nouns (Q147276) and the given forms.
# All Hindi Hindustani (Q11051) proper nouns (Q147276) and the given forms.
# Enter this query at https://query.wikidata.org/.

# Note: We need to filter for "hi" to remove Urdu (ur) words.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# tool: scribe-data
# All Hindi (Q11051) verbs (Q24905) and the given forms.
# All Hindi Hindustani (Q11051) verbs (Q24905) and the given forms.
# Enter this query at https://query.wikidata.org/.

# Note: We need to filter for "hi" to remove Urdu (ur) words.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# tool: scribe-data
# All Urdu (Q11051) adjectives (Q34698) and the given forms.
# All Urdu Hindustani (Q11051) adjectives (Q34698) and the given forms.
# Enter this query at https://query.wikidata.org/.

# Note: We need to filter for "ur" to remove Hindi (hi) words.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# tool: scribe-data
# All Urdu (Q11051) adverbs (Q380057) and the given forms.
# All Urdu Hindustani (Q11051) adverbs (Q380057) and the given forms.
# Enter this query at https://query.wikidata.org/.

# Note: We need to filter for "ur" to remove Hindi (hi) words.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# tool: scribe-data
# All Urdu (Q11051) nouns (Q1084) and the given forms.
# All Urdu Hindustani (Q11051) nouns (Q1084) and the given forms.
# Enter this query at https://query.wikidata.org/.

# Note: We need to filter for "ur" to remove Hindi (hi) words.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# tool: scribe-data
# All Urdu (Q11051) postpositions (Q161873) and the given forms.
# All Urdu Hindustani (Q11051) postpositions (Q161873) and the given forms.
# Enter this query at https://query.wikidata.org/.

# Note: We need to filter for "ur" to remove Hindi (hi) words.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# tool: scribe-data
# All Urdu (Q11051) prepositions (Q4833830) and the given forms.
# All Urdu Hindustani (Q11051) prepositions (Q4833830) and the given forms.
# Enter this query at https://query.wikidata.org/.

# Note: We need to filter for "ur" to remove Hindi (hi) words.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# tool: scribe-data
# All Urdu (Q11051) proper nouns (Q147276) and the given forms.
# All Urdu Hindustani (Q11051) proper nouns (Q147276) and the given forms.
# Enter this query at https://query.wikidata.org/.

# Note: We need to filter for "ur" to remove Hindi (hi) words.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# tool: scribe-data
# All Urdu (Q11051) verbs (Q24905) and the given forms.
# All Urdu Hindustani (Q11051) verbs (Q24905) and the given forms.
# Enter this query at https://query.wikidata.org/.

# Note: We need to filter for "ur" to remove Hindustani (hi) words.
Expand Down

0 comments on commit 60755bd

Please sign in to comment.