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

feat: Deprecate host_definition #29222

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rafaeelaudibert
Copy link
Member

This was an attempt to collect all domains so that we could use it on Web Analytics' UI. We've decided to go a different route because of the problems we'd have with having this inside propdefs. We don't usually drop any tables from our DB, so let's simply tag it as deprecated.

We've also implemented a new @deprecated decorator for python for this usecase, we're using it for a different already-deprecated class as well

This was an attempt to collect all domains so that we could use it on Web Analytics' UI. We've decided to go a different route because of the problems we'd have with having this inside `propdefs`. We don't usually drop any tables from our DB, so let's simply tag it as deprecated.

We've also implemented a new `@deprecated` decorator for python for this usecase, we're using it for a different already-deprecated class as well
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR introduces a new @deprecated decorator in posthog/utils.py to standardize how deprecated components are marked in the codebase.

  • Added a flexible @deprecated decorator that works with both classes and functions, supporting optional reason messages
  • Applied the decorator to HostDefinition model with a clear explanation about performance issues with propdefs
  • Converted the existing Alert class deprecation from a docstring comment to use the new decorator
  • The decorator emits warnings when deprecated code is used, improving visibility of deprecated components
  • Changed direct model imports to string references in HostDefinition to avoid circular import issues

3 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Copy link
Member

@lricoy lricoy left a comment

Choose a reason for hiding this comment

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

I am not sure what to do with the python code quality issues, they seem reasonable enough to fix but for the nature of the decorator, could be ok to ignore as well.

What were you planning to do @rafaeelaudibert ?

@@ -1536,3 +1538,47 @@ def get_from_dict_or_attr(obj: Any, key: str):
return getattr(obj, key, None)
else:
raise AttributeError(f"Object {obj} has no key {key}")


def deprecated(reason: str | None = None):
Copy link
Member

Choose a reason for hiding this comment

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

Python 3.13 actually added this as a built in decorator, there is a link for the docs here and the corresponding PEP: https://docs.python.org/3.13/library/warnings.html#warnings.deprecated

Maybe we could keep the method signature to make this future-proof?

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

Successfully merging this pull request may close these issues.

2 participants