mirror of
https://github.com/natelandau/obsidian-metadata.git
synced 2025-11-18 18:03:39 -05:00
build(deps): bump dependencies
This commit is contained in:
@@ -54,7 +54,7 @@ class ConfigQuestions:
|
||||
class Config:
|
||||
"""Representation of a configuration file."""
|
||||
|
||||
def __init__(self, config_path: Path = None, vault_path: Path = None) -> None:
|
||||
def __init__(self, config_path: Path | None = None, vault_path: Path | None = None) -> None:
|
||||
if vault_path is None:
|
||||
self.config_path: Path = self._validate_config_path(Path(config_path))
|
||||
self.config: dict[str, Any] = self._load_config()
|
||||
|
||||
@@ -87,7 +87,7 @@ def info(msg: str) -> None:
|
||||
console.print(f"INFO | {msg}")
|
||||
|
||||
|
||||
def usage(msg: str, width: int = None) -> None:
|
||||
def usage(msg: str, width: int | None = None) -> None:
|
||||
"""Print a usage message without using logging.
|
||||
|
||||
Args:
|
||||
|
||||
@@ -38,7 +38,7 @@ def clear_screen() -> None: # pragma: no cover
|
||||
|
||||
|
||||
def dict_contains(
|
||||
dictionary: dict[str, list[str]], key: str, value: str = None, is_regex: bool = False
|
||||
dictionary: dict[str, list[str]], key: str, value: str | None = None, is_regex: bool = False
|
||||
) -> bool:
|
||||
"""Check if a dictionary contains a key or if a key contains a value.
|
||||
|
||||
@@ -79,7 +79,7 @@ def dict_keys_to_lower(dictionary: dict) -> dict:
|
||||
|
||||
|
||||
def delete_from_dict( # noqa: C901
|
||||
dictionary: dict, key: str, value: str = None, is_regex: bool = False
|
||||
dictionary: dict, key: str, value: str | None = None, is_regex: bool = False
|
||||
) -> dict:
|
||||
"""Delete a key or a value from a dictionary.
|
||||
|
||||
@@ -172,7 +172,7 @@ def merge_dictionaries(dict1: dict, dict2: dict) -> dict:
|
||||
|
||||
|
||||
def rename_in_dict(
|
||||
dictionary: dict[str, list[str]], key: str, value_1: str, value_2: str = None
|
||||
dictionary: dict[str, list[str]], key: str, value_1: str, value_2: str | None = None
|
||||
) -> dict:
|
||||
"""Rename a key or a value in a dictionary who's values are lists of strings.
|
||||
|
||||
|
||||
@@ -186,10 +186,10 @@ class Note:
|
||||
is_regex=True,
|
||||
)
|
||||
|
||||
return False
|
||||
return False # type: ignore [unreachable]
|
||||
|
||||
def _edit_inline_metadata(
|
||||
self, source: InlineField, new_key: str, new_value: str = None
|
||||
self, source: InlineField, new_key: str, new_value: str | None = None
|
||||
) -> InlineField:
|
||||
"""Edit an inline metadata field. Takes an InlineField object and a new key and/or value and edits the inline metadata in the object and note accordingly.
|
||||
|
||||
@@ -235,7 +235,11 @@ class Note:
|
||||
return new_inline_field
|
||||
|
||||
def _find_matching_fields(
|
||||
self, meta_type: MetadataType, key: str = None, value: str = None, is_regex: bool = False
|
||||
self,
|
||||
meta_type: MetadataType,
|
||||
key: str | None = None,
|
||||
value: str | None = None,
|
||||
is_regex: bool = False,
|
||||
) -> list[InlineField]:
|
||||
"""Create a list of InlineField objects matching the specified key and/or value.
|
||||
|
||||
@@ -295,7 +299,7 @@ class Note:
|
||||
return matching_inline_fields
|
||||
|
||||
def _update_inline_metadata(
|
||||
self, source: InlineField, new_key: str = None, new_value: str = None
|
||||
self, source: InlineField, new_key: str | None = None, new_value: str | None = None
|
||||
) -> bool:
|
||||
"""Update an inline metadata field. Takes an InlineField object and a new key and/or value and updates the inline metadata in the object and note accordingly.
|
||||
|
||||
@@ -354,8 +358,8 @@ class Note:
|
||||
def add_metadata(
|
||||
self,
|
||||
meta_type: MetadataType,
|
||||
added_key: str = None,
|
||||
added_value: str = None,
|
||||
added_key: str | None = None,
|
||||
added_value: str | None = None,
|
||||
location: InsertLocation = None,
|
||||
) -> bool:
|
||||
"""Add metadata to the note if it does not already exist. This method adds specified metadata to the appropriate MetadataType object AND writes the new metadata to the note's file.
|
||||
@@ -428,7 +432,7 @@ class Note:
|
||||
)
|
||||
raise typer.Exit(code=1)
|
||||
|
||||
def commit(self, path: Path = None) -> None:
|
||||
def commit(self, path: Path | None = None) -> None:
|
||||
"""Write the note's new content to disk. This is a destructive action.
|
||||
|
||||
Args:
|
||||
@@ -453,7 +457,7 @@ class Note:
|
||||
self,
|
||||
meta_type: MetadataType,
|
||||
search_key: str,
|
||||
search_value: str = None,
|
||||
search_value: str | None = None,
|
||||
is_regex: bool = False,
|
||||
) -> bool:
|
||||
"""Check if a note contains the specified metadata.
|
||||
@@ -514,7 +518,11 @@ class Note:
|
||||
return False
|
||||
|
||||
def delete_metadata( # noqa: PLR0912, C901
|
||||
self, meta_type: MetadataType, key: str = None, value: str = None, is_regex: bool = False
|
||||
self,
|
||||
meta_type: MetadataType,
|
||||
key: str | None = None,
|
||||
value: str | None = None,
|
||||
is_regex: bool = False,
|
||||
) -> bool:
|
||||
"""Delete specified metadata from the note. Removes the metadata from the note and the metadata list. When a key is provided without a value, all values associated with that key are deleted.
|
||||
|
||||
@@ -661,7 +669,7 @@ class Note:
|
||||
"""Print the note to the console."""
|
||||
console_no_markup.print(self.file_content)
|
||||
|
||||
def rename_metadata(self, key: str, value_1: str, value_2: str = None) -> bool:
|
||||
def rename_metadata(self, key: str, value_1: str, value_2: str | None = None) -> bool:
|
||||
"""Rename a key or key-value pair in the note's InlineMetadata and Frontmatter objects and the content of the note.
|
||||
|
||||
If no value is provided, will rename the entire specified key.
|
||||
@@ -770,8 +778,8 @@ class Note:
|
||||
self,
|
||||
begin: MetadataType,
|
||||
end: MetadataType,
|
||||
key: str = None,
|
||||
value: str = None,
|
||||
key: str | None = None,
|
||||
value: str | None = None,
|
||||
location: InsertLocation = InsertLocation.BOTTOM,
|
||||
) -> bool:
|
||||
"""Move metadata from one metadata object to another. i.e. Frontmatter to InlineMetadata or vice versa.
|
||||
|
||||
@@ -63,7 +63,7 @@ class Questions:
|
||||
|
||||
return True
|
||||
|
||||
def __init__(self, vault: Vault = None, key: str = None) -> None:
|
||||
def __init__(self, vault: Vault = None, key: str | None = None) -> None:
|
||||
"""Initialize the class.
|
||||
|
||||
Args:
|
||||
|
||||
@@ -231,8 +231,8 @@ class Vault:
|
||||
def add_metadata(
|
||||
self,
|
||||
meta_type: MetadataType,
|
||||
key: str = None,
|
||||
value: str = None,
|
||||
key: str | None = None,
|
||||
value: str | None = None,
|
||||
location: InsertLocation = None,
|
||||
) -> int:
|
||||
"""Add metadata to all notes in the vault which do not already contain it.
|
||||
@@ -303,7 +303,7 @@ class Vault:
|
||||
_note.commit()
|
||||
|
||||
def contains_metadata(
|
||||
self, meta_type: MetadataType, key: str, value: str = None, is_regex: bool = False
|
||||
self, meta_type: MetadataType, key: str, value: str | None = None, is_regex: bool = False
|
||||
) -> bool:
|
||||
"""Check if the vault contains metadata.
|
||||
|
||||
@@ -374,7 +374,7 @@ class Vault:
|
||||
def delete_metadata(
|
||||
self,
|
||||
key: str,
|
||||
value: str = None,
|
||||
value: str | None = None,
|
||||
meta_type: MetadataType = MetadataType.ALL,
|
||||
is_regex: bool = False,
|
||||
) -> int:
|
||||
@@ -490,8 +490,7 @@ class Vault:
|
||||
if _note.has_changes():
|
||||
changed_notes.append(_note)
|
||||
|
||||
changed_notes = sorted(changed_notes, key=lambda x: x.note_path)
|
||||
return changed_notes
|
||||
return sorted(changed_notes, key=lambda x: x.note_path)
|
||||
|
||||
def info(self) -> None:
|
||||
"""Print information about the vault."""
|
||||
@@ -613,7 +612,7 @@ class Vault:
|
||||
|
||||
return num_changed
|
||||
|
||||
def rename_metadata(self, key: str, value_1: str, value_2: str = None) -> int:
|
||||
def rename_metadata(self, key: str, value_1: str, value_2: str | None = None) -> int:
|
||||
"""Rename a key or key-value pair in the note's metadata.
|
||||
|
||||
If no value is provided, will rename an entire key.
|
||||
@@ -642,8 +641,8 @@ class Vault:
|
||||
self,
|
||||
begin: MetadataType,
|
||||
end: MetadataType,
|
||||
key: str = None,
|
||||
value: str = None,
|
||||
key: str | None = None,
|
||||
value: str | None = None,
|
||||
location: InsertLocation = None,
|
||||
) -> int:
|
||||
"""Transpose metadata from one type to another.
|
||||
|
||||
Reference in New Issue
Block a user