Skip to content

ref(py): Consistently use import * in models #89444

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

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 7 additions & 7 deletions src/sentry/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from .broadcast import * # NOQA
from .commit import * # NOQA
from .commitauthor import * # NOQA
from .commitfilechange import CommitFileChange # noqa
from .commitfilechange import * # noqa
from .counter import * # NOQA
from .dashboard import * # NOQA
from .dashboard_permissions import * # NOQA
Expand Down Expand Up @@ -69,7 +69,7 @@
from .organizationaccessrequest import * # NOQA
from .organizationmapping import * # NOQA
from .organizationmember import * # NOQA
from .organizationmemberinvite import OrganizationMemberInvite # NOQA
from .organizationmemberinvite import * # NOQA
from .organizationmembermapping import * # NOQA
from .organizationmemberteam import * # NOQA
from .organizationmemberteamreplica import * # NOQA
Expand All @@ -81,12 +81,12 @@
from .projectbookmark import * # NOQA
from .projectcodeowners import * # NOQA
from .projectkey import * # NOQA
from .projectownership import ProjectOwnership # NOQA
from .projectownership import * # NOQA
from .projectplatform import * # NOQA
from .projectredirect import * # NOQA
from .projectsdk import * # NOQA
from .projectteam import ProjectTeam # noqa
from .projecttemplate import ProjectTemplate # noqa
from .projectteam import * # NOQA
from .projecttemplate import * # NOQA
from .promptsactivity import * # NOQA
from .pullrequest import * # NOQA
from .recentsearch import * # NOQA
Expand All @@ -104,8 +104,8 @@
from .rollbackorganization import * # NOQA
from .rollbackuser import * # NOQA
from .rule import * # NOQA
from .rulefirehistory import RuleFireHistory # NOQA
from .rulesnooze import RuleSnooze # NOQA
from .rulefirehistory import * # NOQA
Copy link
Member

@mjq mjq Apr 14, 2025

Choose a reason for hiding this comment

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

Even though rulefirehistory only contains RuleFireHistory, would it still make sense to add an explicit __all__ to avoid inadvertently importing something later via this pattern?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah let me follow up there

from .rulesnooze import * # NOQA
from .savedsearch import * # NOQA
from .search_common import * # NOQA
from .sentryshot import * # NOQA
Expand Down
3 changes: 3 additions & 0 deletions src/sentry/models/commitfilechange.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
COMMIT_FILE_CHANGE_TYPES = frozenset(("A", "D", "M"))


__all__ = ("CommitFileChange",)


class CommitFileChangeManager(BaseManager["CommitFileChange"]):
def get_count_for_commits(self, commits: Iterable[Any]) -> int:
return int(self.filter(commit__in=commits).values("filename").distinct().count())
Expand Down
2 changes: 2 additions & 0 deletions src/sentry/models/organizationmemberinvite.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

INVITE_DAYS_VALID = 30

__all__ = ("OrganizationMemberInvite",)


class InviteStatus(Enum):
APPROVED = 0
Expand Down
2 changes: 2 additions & 0 deletions src/sentry/models/projectownership.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
from sentry.models.team import Team
from sentry.users.services.user import RpcUser

__all__ = ("ProjectOwnership",)

logger = logging.getLogger(__name__)
READ_CACHE_DURATION = 3600

Expand Down
2 changes: 2 additions & 0 deletions src/sentry/models/projectteam.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
if TYPE_CHECKING:
from sentry.models.team import Team

__all__ = ("ProjectTeam",)


class ProjectTeamManager(BaseManager["ProjectTeam"]):
def get_for_teams_with_org_cache(self, teams: Sequence["Team"]) -> QuerySet["ProjectTeam"]:
Expand Down
2 changes: 2 additions & 0 deletions src/sentry/models/projecttemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
sane_repr,
)

__all__ = ("ProjectTemplate",)


@region_silo_model
class ProjectTemplate(DefaultFieldsModelExisting):
Expand Down
2 changes: 2 additions & 0 deletions src/sentry/models/rulesnooze.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from sentry.db.models.fields.hybrid_cloud_foreign_key import HybridCloudForeignKey
from sentry.db.models.manager.base import BaseManager

__all__ = ("RuleSnooze",)


class RuleSnoozeManager(BaseManager["RuleSnooze"]):
def is_snoozed_for_all(self, rule=None, alert_rule=None):
Expand Down
Loading