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

W-17092332: Fix for updating functions without is_public set #650

Merged
merged 4 commits into from
Oct 31, 2024
Merged
Changes from 3 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
7 changes: 6 additions & 1 deletion tabpy/tabpy_server/management/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,12 @@ def update_endpoint(
endpoint_type, endpoint_info["type"])
dependencies = self._check_and_set_dependencies(
dependencies, endpoint_info.get("dependencies", []))
is_public = self._check_and_set_is_public(is_public, endpoint_info["is_public"])
# Adding is_public means that some existing functions do not have is_public set.
# We need to check for this when updating and set to False by default
current_is_public = False
if hasattr(endpoint_info, "is_public"):
current_is_public = endpoint_info["is_public"]
is_public = self._check_and_set_is_public(is_public, current_is_public)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Another option with getattr:

is_public = self._check_and_set_is_public(is_public, getattr(endpoint_info, "is_public", False))

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this. Much neater.


self._check_target(target)
if target and target not in endpoints:
Expand Down
Loading