Skip to content

Fill in blank exception messages #801

@tjlaboss

Description

@tjlaboss

Issue #800 identified blank TypeError messages in material.py. While specifying a message is optional in Python, if an exception does include a message, it should not be blank.

Here are the instances:


data_inputs/material.py

L65

 def __setitem__(self, key, value):
        key = self._validate_key(key)
        if not isinstance(value, (Library, str)):
            raise TypeError("")

L94

    @staticmethod
    def _validate_key(key):
        if not isinstance(key, (str, LibraryType)):
            raise TypeError("")
        if not isinstance(key, LibraryType):
            key = LibraryType(key.upper())
        return key

numbered_object_collection.py

L362

    def remove(self, delete):
        """Removes the given object from the collection.

        Parameters
        ----------
        delete : Numbered_MCNP_Object
            the object to delete
        """
        if not isinstance(delete, self._obj_class):
            raise TypeError("")
        candidate = self[delete.number]
        if delete is candidate:
            del self[delete.number]
        else:
            raise KeyError(f"This object is not in this collection")

There is also another case in input_parser/syntax_node.py at L1967 that appears to be intentional (creating the warning in a roundabout way).

Metadata

Metadata

Assignees

Labels

code improvementA feature request that will improve the software and its maintainability, but be invisible to users.good first issueGood for newcomershacktoberfest🎃 https://hacktoberfest.com/participation/low priority

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions