Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError in graph_tool #121

Open
jtseven opened this issue May 11, 2023 · 0 comments
Open

KeyError in graph_tool #121

jtseven opened this issue May 11, 2023 · 0 comments

Comments

@jtseven
Copy link

jtseven commented May 11, 2023

Within the get_node_type method in graph_tool.py there is an if-clause to check, if a certain key exists in graph.keys(), but if it fails, accessing the key is still tried and will fail with a KeyError:

def get_node_type(self, name):
    if name in self.graph.keys() and "attr" in self.graph[name].keys():  # <-- Check if name is in keys
        return self.graph[name]["attr"]["type"]
    else:
        logging.info(name, self.graph[name])  # <-- Causes key error
    return None

Instead, something like that could be done:

logging.info(name, self.graph.get(name, "Name not in graph"))

I'm not sure if it is expected behavior that the name does not exist within the keys. If it's not, a different, more precise error message should be printed and an exception should be raised accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant