Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/usethis/_integrations/ci/bitbucket/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def bitbucket_fancy_dump(
if not isinstance(dump, dict):
msg = (
f"Invalid '{type(config)}' representation when dumping; expected dict, got "
f"{type(dump)}"
f"{type(dump)}."
)
raise TypeError(msg)

Expand Down
2 changes: 1 addition & 1 deletion src/usethis/_integrations/ci/bitbucket/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
try:
script_item = _SCRIPT_ITEM_LOOKUP[script_item.name]
except KeyError:
msg = f"Unrecognized script item anchor: {script_item.name}"
msg = f"Unrecognized script item anchor: '{script_item.name}'."

Check warning on line 129 in src/usethis/_integrations/ci/bitbucket/steps.py

View check run for this annotation

Codecov / codecov/patch

src/usethis/_integrations/ci/bitbucket/steps.py#L129

Added line #L129 was not covered by tests
raise NotImplementedError(msg) from None

if config.definitions is None:
Expand Down
4 changes: 2 additions & 2 deletions src/usethis/_integrations/ci/github/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ def get_github_latest_tag(owner: str, repo: str) -> str:
response = requests.get(api_url, timeout=1)
response.raise_for_status() # Raise an error for HTTP issues
except (requests.exceptions.HTTPError, requests.exceptions.ConnectionError) as err:
msg = f"Failed to fetch tags from GitHub API: {err}"
msg = f"Failed to fetch tags from GitHub API:\n{err}"
raise GitHubTagError(msg) from None

tags = response.json()

if not tags:
msg = f"No tags found for repository '{owner}/{repo}'"
msg = f"No tags found for repository '{owner}/{repo}'."
raise NoGitHubTagsFoundError(msg)

# Most recent tag's name
Expand Down
36 changes: 18 additions & 18 deletions src/usethis/_integrations/file/ini/io_.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
except UnexpectedFileIOError as err:
raise UnexpectedINIIOError(err) from None
except configparser.ParsingError as err:
msg = f"Failed to decode '{self.name}': {err}"
msg = f"Failed to decode '{self.name}':\n{err}"
raise INIDecodeError(msg) from None

def _dump_content(self) -> str:
Expand Down Expand Up @@ -142,7 +142,7 @@
else:
msg = (
f"INI files do not support nested config, whereas access to "
f"'{self.name}' was attempted at '{print_keys(keys)}'"
f"'{self.name}' was attempted at '{print_keys(keys)}'."
)
raise KeyError(msg)

Expand Down Expand Up @@ -174,7 +174,7 @@
else:
msg = (
f"INI files do not support nested config, whereas access to "
f"'{self.name}' was attempted at '{print_keys(keys)}'"
f"'{self.name}' was attempted at '{print_keys(keys)}'."
)
raise ININestingError(msg)

Expand All @@ -187,7 +187,7 @@
root_dict = value

if any(root) and not exists_ok:
msg = "The INI file already has content at the root level"
msg = "The INI file already has content at the root level."
raise INIValueAlreadySetError(msg)

# We need to remove section that are not in the new dict
Expand Down Expand Up @@ -237,7 +237,9 @@

if section_key in root:
if not exists_ok:
msg = f"The INI file already has content at the section '{section_key}'"
msg = (
f"The INI file already has content at the section '{section_key}'."
)
raise INIValueAlreadySetError(msg)

if not isinstance(section_key, str):
Expand Down Expand Up @@ -282,7 +284,7 @@
if root.has_option(section=section_key, option=option_key) and not exists_ok:
msg = (
f"The INI file already has content at the section '{section_key}' "
f"and option '{option_key}'"
f"and option '{option_key}'."
)
raise INIValueAlreadySetError(msg)

Expand Down Expand Up @@ -371,14 +373,12 @@
else:
msg = (
f"INI files do not support nested config, whereas access to "
f"'{self.name}' was attempted at '{print_keys(keys)}'"
f"'{self.name}' was attempted at '{print_keys(keys)}'."
)
raise ININestingError(msg)

if not seqs:
msg = (
f"INI file '{self.name}' does not contain the keys '{print_keys(keys)}'"
)
msg = f"INI file '{self.name}' does not contain the keys '{print_keys(keys)}'."
raise INIValueMissingError(msg)

for seq in seqs:
Expand Down Expand Up @@ -412,12 +412,12 @@
else:
msg = (
f"INI files do not support nested config, whereas access to "
f"'{self.name}' was attempted at '{print_keys(strkeys)}'"
f"'{self.name}' was attempted at '{print_keys(strkeys)}'."
)
raise ININestingError(msg)

if not removed:
msg = f"INI file '{self.name}' does not contain the keys '{print_keys(strkeys)}'"
msg = f"INI file '{self.name}' does not contain the keys '{print_keys(strkeys)}'."

Check warning on line 420 in src/usethis/_integrations/file/ini/io_.py

View check run for this annotation

Codecov / codecov/patch

src/usethis/_integrations/file/ini/io_.py#L420

Added line #L420 was not covered by tests
raise INIValueMissingError(msg)

self.commit(root)
Expand All @@ -432,13 +432,13 @@
if len(keys) == 0:
msg = (
f"INI files do not support lists at the root level, whereas access to "
f"'{self.name}' was attempted at '{print_keys(keys)}'"
f"'{self.name}' was attempted at '{print_keys(keys)}'."
)
raise InvalidINITypeError(msg)
elif len(keys) == 1:
msg = (
f"INI files do not support lists at the section level, whereas access "
f"to '{self.name}' was attempted at '{print_keys(keys)}'"
f"to '{self.name}' was attempted at '{print_keys(keys)}'."
)
raise InvalidINITypeError(msg)
elif len(keys) == 2:
Expand All @@ -449,7 +449,7 @@
else:
msg = (
f"INI files do not support nested config, whereas access to "
f"'{self.name}' was attempted at '{print_keys(keys)}'"
f"'{self.name}' was attempted at '{print_keys(keys)}'."
)
raise ININestingError(msg)

Expand Down Expand Up @@ -509,13 +509,13 @@
if len(keys) == 0:
msg = (
f"INI files do not support lists at the root level, whereas access to "
f"'{self.name}' was attempted at '{print_keys(keys)}'"
f"'{self.name}' was attempted at '{print_keys(keys)}'."
)
raise InvalidINITypeError(msg)
elif len(keys) == 1:
msg = (
f"INI files do not support lists at the section level, whereas access "
f"to '{self.name}' was attempted at '{print_keys(keys)}'"
f"to '{self.name}' was attempted at '{print_keys(keys)}'."
)
raise InvalidINITypeError(msg)
elif len(keys) == 2:
Expand All @@ -526,7 +526,7 @@
else:
msg = (
f"INI files do not support nested config, whereas access to "
f"'{self.name}' was attempted at '{print_keys(keys)}'"
f"'{self.name}' was attempted at '{print_keys(keys)}'."
)
raise ININestingError(msg)

Expand Down
6 changes: 2 additions & 4 deletions src/usethis/_integrations/file/pyproject_toml/name.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ def get_name() -> str:
msg = "The 'project.name' value is missing from 'pyproject.toml'."
raise PyprojectTOMLProjectNameError(msg) from None
except ValidationError as err:
msg = (
f"The 'project.name' value in 'pyproject.toml' is not a valid string: {err}"
)
msg = f"The 'project.name' value in 'pyproject.toml' is not a valid string:\n{err}"
raise PyprojectTOMLProjectNameError(msg) from None

return name
Expand All @@ -36,7 +34,7 @@ def get_description() -> str:
msg = "The 'project.description' value is missing from 'pyproject.toml'."
raise PyprojectTOMLProjectDescriptionError(msg) from None
except ValidationError as err:
msg = f"The 'project.description' value in 'pyproject.toml' is not a valid string: {err}"
msg = f"The 'project.description' value in 'pyproject.toml' is not a valid string:\n{err}"
raise PyprojectTOMLProjectDescriptionError(msg) from None

return description
2 changes: 1 addition & 1 deletion src/usethis/_integrations/file/pyproject_toml/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def get_project_dict() -> dict[str, Any]:
msg = "The 'project' section is missing from 'pyproject.toml'."
raise PyprojectTOMLProjectSectionError(msg) from None
except ValidationError as err:
msg = f"The 'project' section in 'pyproject.toml' is not a valid map: {err}"
msg = f"The 'project' section in 'pyproject.toml' is not a valid map:\n{err}"
raise PyprojectTOMLProjectSectionError(msg) from None

return project
2 changes: 1 addition & 1 deletion src/usethis/_integrations/file/pyproject_toml/valid.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _ensure_project_section(toml_document: TOMLDocument) -> Table:

project = toml_document["project"]
if not isinstance(project, Table):
msg = f"Expected 'project' to be a TOML Table, got {type(project)}."
msg = f"Expected 'project' to be a TOML Table, got '{type(project)}'."
raise TypeError(msg)

return project
Expand Down
2 changes: 1 addition & 1 deletion src/usethis/_integrations/file/toml/io_.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def read_file(self) -> None:
except UnexpectedFileIOError as err:
raise UnexpectedTOMLIOError(err) from None
except TOMLKitError as err:
msg = f"Failed to decode '{self.name}': {err}"
msg = f"Failed to decode '{self.name}':\n{err}"
raise TOMLDecodeError(msg) from None

def _dump_content(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion src/usethis/_integrations/file/yaml/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"""
"""Update the values of a ruamel.yaml map in-place using a diff-like algorithm."""
if not isinstance(cmap, CommentedMap):
msg = f"Expected CommentedMap, but got {type(cmap)}."
msg = f"Expected CommentedMap, but got '{type(cmap)}'."

Check warning on line 36 in src/usethis/_integrations/file/yaml/update.py

View check run for this annotation

Codecov / codecov/patch

src/usethis/_integrations/file/yaml/update.py#L36

Added line #L36 was not covered by tests
raise TypeError(msg)

if not preserve_comments:
Expand Down
2 changes: 1 addition & 1 deletion src/usethis/_integrations/pre_commit/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def pre_commit_fancy_dump(
if not isinstance(dump, dict):
msg = (
f"Invalid '{type(config)}' representation when dumping; expected dict, got "
f"{type(dump)}"
f"'{type(dump)}'."
)
raise TypeError(msg)

Expand Down
4 changes: 2 additions & 2 deletions src/usethis/_integrations/pre_commit/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
(hook_config,) = repo.hooks

if hook_config.id is None:
msg = "Hook ID must be specified"
msg = "The hook ID must be specified."

Check warning on line 52 in src/usethis/_integrations/pre_commit/hooks.py

View check run for this annotation

Codecov / codecov/patch

src/usethis/_integrations/pre_commit/hooks.py#L52

Added line #L52 was not covered by tests
raise ValueError(msg)

# Ordered list of the hooks already in the file
Expand All @@ -72,7 +72,7 @@
try:
hook_idx = _HOOK_ORDER.index(hook_config.id)
except ValueError:
msg = f"Hook '{hook_config.id}' not recognized"
msg = f"Hook '{hook_config.id}' not recognized."
raise NotImplementedError(msg) from None
precedents = _HOOK_ORDER[:hook_idx]
successors = _HOOK_ORDER[hook_idx + 1 :]
Expand Down
4 changes: 2 additions & 2 deletions src/usethis/_integrations/sonarqube/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
def _get_short_version(version: str) -> str:
match = re.match(r"^(\d{1,2}\.\d{1,2})", version)
if match is None:
msg = f"Could not parse Python version from {version}"
msg = f"Could not parse Python version from '{version}'."

Check warning on line 89 in src/usethis/_integrations/sonarqube/config.py

View check run for this annotation

Codecov / codecov/patch

src/usethis/_integrations/sonarqube/config.py#L89

Added line #L89 was not covered by tests
raise _NonstandardPythonVersionError(msg)

return match.group(1)
Expand All @@ -109,5 +109,5 @@
"""
_RE = r"^[a-zA-Z0-9\-_:.]+$"
if re.match(_RE, project_key) is None or project_key.isdigit():
msg = f"Invalid SonarQube project key: {project_key}"
msg = f"Invalid SonarQube project key: '{project_key}'."
raise InvalidSonarQubeProjectKeyError(msg)
2 changes: 1 addition & 1 deletion src/usethis/_integrations/uv/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
if match:
return match.group(1)
else:
msg = f"Could not parse version from {version}"
msg = f"Could not parse version from '{version}'."

Check warning on line 46 in src/usethis/_integrations/uv/python.py

View check run for this annotation

Codecov / codecov/patch

src/usethis/_integrations/uv/python.py#L46

Added line #L46 was not covered by tests
raise UVUnparsedPythonVersionError(msg)


Expand Down
4 changes: 2 additions & 2 deletions src/usethis/_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def read_file(self) -> None:
try:
self._content = self._parse_content(self.path.read_text())
except FileNotFoundError:
msg = f"'{self.name}' not found in the current directory at '{self.path}'"
msg = f"'{self.name}' not found in the current directory at '{self.path}'."
raise FileNotFoundError(msg) from None

@abstractmethod
Expand All @@ -157,7 +157,7 @@ def _validate_lock(self) -> None:
if not self.is_locked():
msg = (
f"The '{self.name}' file has not been opened yet. Please enter the "
f"context manager, e.g. 'with {self.__class__.__name__}():'"
f"context manager, e.g. 'with {self.__class__.__name__}():'."
)
raise UnexpectedFileIOError(msg)

Expand Down
6 changes: 3 additions & 3 deletions src/usethis/_pipeweld/func.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
partition.postrequisite_component,
)
if component is None:
msg = "Flatten failed: no components"
msg = "Flatten failed: no components."
raise ValueError(msg)
return component

Expand Down Expand Up @@ -584,7 +584,7 @@
except ValueError:
pass

msg = """No endpoints are defined for a Series with no steps"""
msg = "No endpoints are defined for a Series with no steps."

Check warning on line 587 in src/usethis/_pipeweld/func.py

View check run for this annotation

Codecov / codecov/patch

src/usethis/_pipeweld/func.py#L587

Added line #L587 was not covered by tests
raise ValueError(msg)
elif isinstance(component, Parallel):
endpoints = []
Expand All @@ -594,7 +594,7 @@
# Any endpoint will do so choose the first one
# alphabetically
if not endpoints:
msg = """No endpoints are defined for a Parallel block with no steps"""
msg = "No endpoints are defined for a Parallel block with no steps."

Check warning on line 597 in src/usethis/_pipeweld/func.py

View check run for this annotation

Codecov / codecov/patch

src/usethis/_pipeweld/func.py#L597

Added line #L597 was not covered by tests
raise ValueError(msg)
return sorted(endpoints)[0]
elif isinstance(component, DepGroup):
Expand Down
8 changes: 3 additions & 5 deletions src/usethis/_tool/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def _get_active_config_file_managers_from_resolution(
msg = (
f"The preferred file manager '{preferred_file_manager}' is not "
f"among the file managers '{file_managers}' for the tool "
f"'{self.name}'"
f"'{self.name}'."
)
raise NotImplementedError(msg)
return {preferred_file_manager}
Expand Down Expand Up @@ -385,7 +385,7 @@ def add_configs(self) -> None:

if not file_managers:
if config_item.applies_to_all:
msg = f"No active config file managers found for one of the '{self.name}' config items"
msg = f"No active config file managers found for one of the '{self.name}' config items."
raise NotImplementedError(msg)
else:
# Early exist; this config item is not managed by any active files
Expand All @@ -399,9 +399,7 @@ def add_configs(self) -> None:
in {file_manager.relative_path for file_manager in file_managers}
]
if not config_entries:
msg = (
f"No config entries found for one of the '{self.name}' config items"
)
msg = f"No config entries found for one of the '{self.name}' config items."
raise NotImplementedError(msg)
if len(config_entries) != 1:
msg = (
Expand Down
2 changes: 1 addition & 1 deletion src/usethis/_tool/impl/import_linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@
elif isinstance(file_manager, SetupCFGManager | DotImportLinterManager):
return ["importlinter", "root_package"] in file_manager
else:
msg = f"Unsupported file manager: {file_manager}"
msg = f"Unsupported file manager: '{file_manager}'."

Check warning on line 309 in src/usethis/_tool/impl/import_linter.py

View check run for this annotation

Codecov / codecov/patch

src/usethis/_tool/impl/import_linter.py#L309

Added line #L309 was not covered by tests
raise NotImplementedError(msg)

def get_pre_commit_config(self) -> PreCommitConfig:
Expand Down
2 changes: 1 addition & 1 deletion src/usethis/_tool/impl/pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def get_active_config_file_managers(self) -> set[KeyValueFileManager]:
msg = (
f"The preferred file manager '{preferred_file_manager}' is not "
f"among the file managers '{file_managers}' for the tool "
f"'{self.name}'"
f"'{self.name}'."
)
raise NotImplementedError(msg)
return {preferred_file_manager}
Expand Down
Loading