Skip to content

Commit

Permalink
code cleanup: (#1793)
Browse files Browse the repository at this point in the history
* rmv "infra": ":metro:" as it is a repeat
* fix broken docstrings
* shield mutable default args
  • Loading branch information
bendichter authored Apr 18, 2024
1 parent bff4f0c commit d7b3793
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pdf_build_src/process_markdowns.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ def correct_tables(root_path, debug=False):
for i, new_line in enumerate(content):
if i == start_line:
new_content.pop()
if i >= start_line and i < end_line:
if start_line <= i < end_line:
new_content.append("|".join(table[count]) + " \n")
count += 1
elif i == end_line:
Expand Down
3 changes: 1 addition & 2 deletions tools/add_contributors.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ def emoji_map(reverse=False) -> dict[str, str]:
"tutorial": ":check_mark_button:",
"maintenance": ":construction:",
"financial": ":dollar_banknote:",
"infra": ":metro:",
}


Expand Down Expand Up @@ -333,7 +332,7 @@ def update_tributors(
"""ALLCONTRIB"""


def load_allcontrib(allcontrib_file: Path) -> None:
def load_allcontrib(allcontrib_file: Path) -> dict:
"""Load `.all-contributorsrc` file."""
with open(allcontrib_file, "r", encoding="utf8") as input_file:
return json.load(input_file)
Expand Down
2 changes: 1 addition & 1 deletion tools/mkdocs_macros_bids/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def make_metadata_table(field_info, src_path=None):
Parameters
----------
field_names : dict
field_info : dict
A list of the field names.
Field names correspond to filenames in the "metadata" directory of the
schema.
Expand Down
2 changes: 1 addition & 1 deletion tools/schemacode/bidsschematools/render/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def make_entity_table(schema, tablefmt="github", src_path=None, **kwargs):
Parameters
----------
schema_path : str
schema : str
Directory containing schema, which is stored in yaml files.
tablefmt : string, optional
The target table format. The default is "github" (GitHub format).
Expand Down
4 changes: 0 additions & 4 deletions tools/schemacode/bidsschematools/render/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,10 +559,6 @@ def render_text(schema, key: str, src_path=None):
schema : dict
The BIDS schema.
object : str
The object to render the description for:
possible values correspond to the keys in schema["objects"].
key : str
The key of the object to render the description for:
possible values correspond to the keys in schema["objects"][object]
Expand Down
2 changes: 1 addition & 1 deletion tools/schemacode/bidsschematools/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def flatten_enums(namespace, inplace=True):
Parameters
----------
schema : dict
namespace : dict
Schema in dictionary form to be flattened.
Returns
Expand Down
16 changes: 12 additions & 4 deletions tools/schemacode/bidsschematools/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ def _get_directory_suffixes(my_schema):

def _get_paths(
bids_paths,
pseudofile_suffixes=[],
pseudofile_suffixes=None,
dummy_paths=False,
exclude_files=[],
exclude_files=None,
):
"""
Get all paths from a list of directories, excluding hidden subdirectories from distribution.
Expand Down Expand Up @@ -166,6 +166,11 @@ def _get_paths(
first.
"""

if exclude_files is None:
exclude_files = []
if pseudofile_suffixes is None:
pseudofile_suffixes = []

path_list = []
bidsignore_list = []
bids_root_found = False
Expand Down Expand Up @@ -387,7 +392,7 @@ def validate_all(
Parameters
----------
bids_paths : list or str
paths_list : list or str
A string pointing to a BIDS directory for which paths should be validated, or a list
of strings pointing to individual files or subdirectories which *all* reside within
one and only one BIDS directory root (i.e. nested datasets should be validated
Expand Down Expand Up @@ -548,7 +553,7 @@ def validate_bids(
report_path=False,
suppress_errors=False,
accept_non_bids_dir=False,
exclude_files=[],
exclude_files=None,
):
"""
Validate paths according to BIDS schema.
Expand Down Expand Up @@ -604,6 +609,9 @@ def validate_bids(
https://github.com/bids-standard/bids-specification/pull/969#issuecomment-1132119492
"""

if exclude_files is None:
exclude_files = []

if isinstance(in_paths, str):
in_paths = [in_paths]

Expand Down

0 comments on commit d7b3793

Please sign in to comment.