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

ref: use absolute imports for models #57281

Merged
merged 1 commit into from
Oct 7, 2023
Merged

Conversation

asottile-sentry
Copy link
Member

@asottile-sentry asottile-sentry commented Oct 2, 2023

created with:

import sentry.conf.server_mypy
import sentry.models

exact = {}
for k, v in sorted(vars(sentry.models).items()):
    if getattr(v, '__module__', '').startswith('sentry.models.'):
        exact[('sentry.models', k)] = v.__module__

exact[('sentry.models', 'ACTOR_TYPES')] = 'sentry.models.actor'
exact[('sentry.models', 'ASSIGNEE_DOES_NOT_EXIST_DURATION')] = 'sentry.models.groupowner'
exact[('sentry.models', 'CRASH_REPORT_TYPES')] = 'sentry.models.eventattachment'
exact[('sentry.models', 'CUSTOM_RULE_DATE_FORMAT')] = 'sentry.models.dynamicsampling'
exact[('sentry.models', 'CUSTOM_RULE_START')] = 'sentry.models.dynamicsampling'
exact[('sentry.models', 'DEFAULT_BLOB_SIZE')] = 'sentry.models.files.utils'
exact[('sentry.models', 'GROUP_OWNER_TYPE')] = 'sentry.models.groupowner'
exact[('sentry.models', 'INBOX_REASON_DETAILS')] = 'sentry.models.groupinbox'
exact[('sentry.models', 'INVITE_DAYS_VALID')] = 'sentry.models.organizationmember'
exact[('sentry.models', 'KEYWORD_MAP')] = 'sentry.models.eventuser'
exact[('sentry.models', 'MAX_FILE_SIZE')] = 'sentry.models.files.utils'
exact[('sentry.models', 'NULL_STRING')] = 'sentry.models.artifactbundle'
exact[('sentry.models', 'QUERY_STATUS_LOOKUP')] = 'sentry.models.group'
exact[('sentry.models', 'SERVICE_HOOK_EVENTS')] = 'sentry.models.servicehook'
exact[('sentry.models', 'TOMBSTONE_FIELDS_FROM_GROUP')] = 'sentry.models.grouptombstone'
exact[('sentry.models', 'process_control_outbox')] = 'sentry.models.outbox'
exact[('sentry.models', 'process_region_outbox')] = 'sentry.models.outbox'

import ast
import collections
from pyupgrade import _main
from pyupgrade._plugins import imports
imports._for_version = lambda *a, **k: ({}, exact, {})
_main.FUNCS = collections.defaultdict(tuple, {ast.Import: [imports.visit_Import], ast.ImportFrom: [imports.visit_ImportFrom]})
_main.fix_tokens = lambda s: s

raise SystemExit(_main.main())

Copy link
Member

@mitsuhiko mitsuhiko left a comment

Choose a reason for hiding this comment

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

Approved in principle. Now to figure out how to merge this :)

@asottile-sentry asottile-sentry marked this pull request as ready for review October 7, 2023 13:52
@asottile-sentry asottile-sentry requested review from a team as code owners October 7, 2023 13:53
@asottile-sentry asottile-sentry requested review from a team October 7, 2023 13:53
@asottile-sentry asottile-sentry requested review from a team as code owners October 7, 2023 13:53
@asottile-sentry asottile-sentry requested a review from a team October 7, 2023 13:53
@asottile-sentry asottile-sentry requested review from a team as code owners October 7, 2023 13:53
@codecov
Copy link

codecov bot commented Oct 7, 2023

Codecov Report

Merging #57281 (c7d491e) into master (996f53a) will increase coverage by 0.11%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master   #57281      +/-   ##
==========================================
+ Coverage   78.93%   79.05%   +0.11%     
==========================================
  Files        5129     5129              
  Lines      221704   222918    +1214     
  Branches    37555    37555              
==========================================
+ Hits       175012   176219    +1207     
- Misses      41057    41063       +6     
- Partials     5635     5636       +1     
Files Coverage Δ
src/sentry/api/authentication.py 81.89% <100.00%> (+0.39%) ⬆️
src/sentry/api/base.py 93.22% <100.00%> (ø)
src/sentry/api/bases/doc_integrations.py 85.71% <100.00%> (ø)
src/sentry/api/bases/external_actor.py 91.39% <100.00%> (+0.18%) ⬆️
src/sentry/api/bases/group.py 96.15% <100.00%> (+0.15%) ⬆️
src/sentry/api/bases/organization.py 92.18% <100.00%> (+0.03%) ⬆️
src/sentry/api/bases/organization_events.py 76.55% <100.00%> (+0.24%) ⬆️
src/sentry/api/bases/organization_integrations.py 78.72% <100.00%> (+0.46%) ⬆️
...rc/sentry/api/bases/organization_request_change.py 100.00% <100.00%> (ø)
src/sentry/api/bases/organizationmember.py 95.23% <100.00%> (+0.11%) ⬆️
... and 283 more

... and 376 files with indirect coverage changes

@asottile-sentry asottile-sentry merged commit 714fabf into master Oct 7, 2023
52 of 53 checks passed
@asottile-sentry asottile-sentry deleted the asottile-models-imports branch October 7, 2023 16:55
@github-actions github-actions bot locked and limited conversation to collaborators Oct 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants