Skip to content

[chore]Make get_field_attr safe and improve control flow in ts_core.py #318

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

Conversation

dardevelin
Copy link

Refactor get_field_attr in library.py:

  • Ensure safety using list slicing to avoid IndexError.
  • Use .get() for dictionary access to handle default cases and prevent KeyError.

Improve control flow in ts_core.py:

  • Remove nesting by exiting early in match_conditions.
  • Eliminate the need for try-catch blocks for better readability and control flow.

Note: Kept existing_fields case unchanged due to add_field_to_entry's procedural nature.

this commit introduces changes to library.py get_field_attr

Refactor get_field_attr in library.py:
- Ensure safety using list slicing to avoid IndexError.
- Use .get() for dictionary access to handle default cases and prevent KeyError.

Improve control flow in ts_core.py:
- Remove nesting by exiting early in match_conditions.
- Eliminate the need for try-catch blocks for better readability and control flow.

Note: Kept existing_fields case unchanged due to add_field_to_entry's procedural nature.

this commit introduces changes to library.py get_field_attr
cleans whitespace from file
Fix get_field_attr in library.py to ensure proper handling of empty keys list:
- Previously, slicing avoided IndexError but returned a list instead.
- Ensure the value is read only if present, defaulting to -1 otherwise.

Ideal scenario: Define this function to return an int, as expected by the software elsewhere.
@dardevelin
Copy link
Author

There is a bug on the assumption for list slicing. Closing and opening a new one with the change fixed

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

Successfully merging this pull request may close these issues.

1 participant