Skip to content
Open
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
58 changes: 37 additions & 21 deletions bin/dump-command-help
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def get_opts(param):
if any_slashes:
any_prefix_is_slash[:] = [True]
if not param.is_flag and not param.count:
rv += " " + param.make_metavar()
rv += f" {param.make_metavar()}"
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function get_opts._write refactored with the following changes:

return rv

rv = [_write(param.opts)]
Expand All @@ -27,7 +27,7 @@ def get_opts(param):

def write_page(out, data):
path = data["path"]
filename = os.path.join(out, *path[1:]) + "/index.rst"
filename = f"{os.path.join(out, *path[1:])}/index.rst"
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function write_page refactored with the following changes:

if len(path) == 1:
filename += ".inc"

Expand All @@ -38,29 +38,44 @@ def write_page(out, data):
pass

args = [x["metavar"] for x in data["arguments"]]
title = "`%s`" % " ".join(data["path"] + args)
body = [title, "-" * len(title), "", data["help"] or ""]
title = f'`{" ".join(data["path"] + args)}`'
body = [
title,
"-" * len(title),
"",
data["help"] or "",
"",
"Options",
"```````",
"",
]


body.append("")
body.append("Options")
body.append("```````")
body.append("")
for opt in data["options"]:
prefix = "- ``%s``: " % opt["opt_string"]
for line in click.wrap_text(opt["help"], 74, prefix, " ").splitlines() or [""]:
body.append(line)
prefix = f'- ``{opt["opt_string"]}``: '
body.extend(
iter(
click.wrap_text(opt["help"], 74, prefix, " ").splitlines()
or [""]
)
)

body.append("- ``--help``: print this help page.")

if data["subcommands"]:
body.append("")
body.append("Subcommands")
body.append("```````````")
body.append("")
body.append(".. toctree::")
body.append(" :maxdepth: 1")
body.append("")
for subcmd in data["subcommands"]:
body.append(f" {subcmd} <{subcmd}/index>")
body.extend(
(
"",
"Subcommands",
"```````````",
"",
".. toctree::",
" :maxdepth: 1",
"",
)
)

body.extend(f" {subcmd} <{subcmd}/index>" for subcmd in data["subcommands"])
body.append("")

with open(filename, "w") as f:
Expand Down Expand Up @@ -88,10 +103,11 @@ def dump_command(out, cmd, path):
help_text = param.help or ""
if param.show_default:
help_text += " [default: %s]" % (
", ".join("%s" % d for d in param.default)
", ".join(f"{d}" for d in param.default)
if isinstance(param.default, (list, tuple))
else (param.default,)
)

Comment on lines -91 to +110
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function dump_command refactored with the following changes:

data["options"].append({"opt_string": get_opts(param), "help": help_text})
else:
data["arguments"].append({"metavar": param.make_metavar()})
Expand Down
7 changes: 1 addition & 6 deletions bin/find-good-catalogs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ MINIMUM = 80


def is_translated(msg):
if isinstance(msg.string, bytes):
return bool(msg.string)
for item in msg.string:
if not item:
return False
return True
return bool(msg.string) if isinstance(msg.string, bytes) else all(msg.string)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function is_translated refactored with the following changes:



@click.command()
Expand Down
2 changes: 1 addition & 1 deletion bin/load-mocks
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def generate_commits(user):
if i == 1:
filename = "raven/base.py"
else:
filename = random.choice(loremipsum.words) + ".js"
filename = f"{random.choice(loremipsum.words)}.js"
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function generate_commits refactored with the following changes:

if random.randint(0, 5) == 1:
author = (user.name, user.email)
else:
Expand Down
2 changes: 1 addition & 1 deletion bin/merge-catalogs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def merge_message(msg, frontend_msg):
@click.command()
@click.argument("locale")
def cli(locale):
catalog_file = "src/sentry/locale/%s/LC_MESSAGES/django.po" % locale
catalog_file = f"src/sentry/locale/{locale}/LC_MESSAGES/django.po"
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function cli refactored with the following changes:

frontend_file = "build/javascript.po"
if not os.path.isfile(frontend_file):
return
Expand Down
14 changes: 7 additions & 7 deletions bin/mock-traces
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def main(slow=False):
org = Organization.get_default()
print(f"Mocking org {org.name}") # NOQA
else:
print("Mocking org {}".format("Default")) # NOQA
print('Mocking org Default')
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function main refactored with the following changes:

org, _ = Organization.objects.get_or_create(slug="default")

for project_name in project_names:
Expand Down Expand Up @@ -54,7 +54,7 @@ def main(slow=False):

timestamp = timezone.now()

print(f" > Loading normal trace") # NOQA
print(" > Loading normal trace")
# Normal trace
create_trace(
slow,
Expand Down Expand Up @@ -94,7 +94,7 @@ def main(slow=False):
},
)

print(f" > Loading orphan data") # NOQA
print(" > Loading orphan data")
# Trace only with orphans
create_trace(
slow,
Expand Down Expand Up @@ -136,7 +136,7 @@ def main(slow=False):
},
)

print(f" > Loading trace with many siblings") # NOQA
print(" > Loading trace with many siblings")
create_trace(
slow,
timestamp - timedelta(milliseconds=random_normal(4000, 250, 1000)),
Expand All @@ -158,7 +158,7 @@ def main(slow=False):
],
},
)
print(f" > Loading trace with many roots") # NOQA
print(" > Loading trace with many roots")
trace_id = uuid4().hex
for _ in range(15):
create_trace(
Expand All @@ -182,7 +182,7 @@ def main(slow=False):
},
)

print(f" > Loading chained trace with orphans") # NOQA
print(" > Loading chained trace with orphans")
trace_id = uuid4().hex
create_trace(
slow,
Expand Down Expand Up @@ -247,7 +247,7 @@ def main(slow=False):
},
)

print(f" > Loading traces missing instrumentation") # NOQA
print(" > Loading traces missing instrumentation")
create_trace(
slow,
timestamp - timedelta(milliseconds=random_normal(4000, 250, 1000)),
Expand Down
2 changes: 1 addition & 1 deletion config/hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ text_type = str
if "VIRTUAL_ENV" in os.environ:
# If pre-commit is not installed outside of the virtualenv, glob will return []
try:
site_packages = glob("%s/lib/*/site-packages" % os.environ["VIRTUAL_ENV"])[0]
site_packages = glob(f'{os.environ["VIRTUAL_ENV"]}/lib/*/site-packages')[0]
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Lines 32-32 refactored with the following changes:

sys.path.insert(0, site_packages)
except IndexError:
pass
Expand Down
46 changes: 15 additions & 31 deletions docker/sentry.conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@
CONF_ROOT = os.path.dirname(__file__)
env = os.environ.get

postgres = env("SENTRY_POSTGRES_HOST") or (env("POSTGRES_PORT_5432_TCP_ADDR") and "postgres")
if postgres:
if postgres := env("SENTRY_POSTGRES_HOST") or (
env("POSTGRES_PORT_5432_TCP_ADDR") and "postgres"
):
Comment on lines -44 to +46
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Lines 44-220 refactored with the following changes:

This removes the following comments ( why? ):

# Cache #
# See https://develop.sentry.dev/services/queue/ for more information on
# configuring your queue broker and workers. Sentry relies on a Python
# requirement, it will optimize several high throughput patterns.
# framework called Celery to manage queues.
# Mail Server #
###############
# Queue #
# Sentry currently utilizes two separate mechanisms. While CACHES is not a
#########

DATABASES = {
"default": {
"ENGINE": "sentry.db.postgres",
Expand Down Expand Up @@ -103,38 +104,25 @@
}
)

#########
# Cache #
#########

# Sentry currently utilizes two separate mechanisms. While CACHES is not a
# requirement, it will optimize several high throughput patterns.

memcached = env("SENTRY_MEMCACHED_HOST") or (env("MEMCACHED_PORT_11211_TCP_ADDR") and "memcached")
if memcached:
if memcached := env("SENTRY_MEMCACHED_HOST") or (
env("MEMCACHED_PORT_11211_TCP_ADDR") and "memcached"
):
memcached_port = env("SENTRY_MEMCACHED_PORT") or "11211"
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.memcached.MemcachedCache",
"LOCATION": [memcached + ":" + memcached_port],
"LOCATION": [f"{memcached}:{memcached_port}"],
"TIMEOUT": 3600,
}
}


# A primary cache is required for things such as processing events
SENTRY_CACHE = "sentry.cache.redis.RedisCache"

#########
# Queue #
#########

# See https://develop.sentry.dev/services/queue/ for more information on
# configuring your queue broker and workers. Sentry relies on a Python
# framework called Celery to manage queues.

rabbitmq = env("SENTRY_RABBITMQ_HOST") or (env("RABBITMQ_PORT_5672_TCP_ADDR") and "rabbitmq")

if rabbitmq:
if rabbitmq := env("SENTRY_RABBITMQ_HOST") or (
env("RABBITMQ_PORT_5672_TCP_ADDR") and "rabbitmq"
):
BROKER_URL = (
"amqp://"
+ (env("SENTRY_RABBITMQ_USERNAME") or env("RABBITMQ_ENV_RABBITMQ_DEFAULT_USER") or "guest")
Expand All @@ -146,7 +134,7 @@
+ (env("SENTRY_RABBITMQ_VHOST") or env("RABBITMQ_ENV_RABBITMQ_DEFAULT_VHOST") or "/")
)
else:
BROKER_URL = "redis://:" + redis_password + "@" + redis + ":" + redis_port + "/" + redis_db
BROKER_URL = f"redis://:{redis_password}@{redis}:{redis_port}/{redis_db}"


###############
Expand Down Expand Up @@ -211,13 +199,9 @@
# 'workers': 1, # the number of web workers
}

###############
# Mail Server #
###############


email = env("SENTRY_EMAIL_HOST") or (env("SMTP_PORT_25_TCP_ADDR") and "smtp")
if email:
if email := env("SENTRY_EMAIL_HOST") or (
env("SMTP_PORT_25_TCP_ADDR") and "smtp"
):
SENTRY_OPTIONS["mail.backend"] = "smtp"
SENTRY_OPTIONS["mail.host"] = email
SENTRY_OPTIONS["mail.password"] = env("SENTRY_EMAIL_PASSWORD") or ""
Expand Down
5 changes: 2 additions & 3 deletions examples/oauth2_consumer_webserver/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@
def index():
access_token = session.get("access_token")
if access_token is None:
return ("<h1>Who are you?</h1>" '<p><a href="{}">Login with Sentry</a></p>').format(
url_for("login")
)
return f'<h1>Who are you?</h1><p><a href="{url_for("login")}">Login with Sentry</a></p>'

Comment on lines -42 to +43
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function index refactored with the following changes:


from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen
Expand Down
2 changes: 1 addition & 1 deletion fixtures/apidocs_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ def create_event(self, name, **kwargs):
"user": {"id": self.user.id, "email": self.user.email},
"release": name,
}
data.update(kwargs)
data |= kwargs
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function APIDocsTestCase.create_event refactored with the following changes:


return self.store_event(data=data, project_id=self.project.id)
3 changes: 1 addition & 2 deletions fixtures/integrations/jira/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ def get_create_meta_for_project(self, project):
"""
self._throw_if_broken()

createmeta = self._get_data(project, "createmeta")
if createmeta:
if createmeta := self._get_data(project, "createmeta"):
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function MockJira.get_create_meta_for_project refactored with the following changes:

return createmeta

# Fallback to stub data
Expand Down
3 changes: 1 addition & 2 deletions fixtures/integrations/stub_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ def get_stub_data(service_name, name):
:return: object
"""
cache_key = f"{service_name}.{name}"
cached = StubService.stub_data_cache.get(cache_key)
if cached:
if cached := StubService.stub_data_cache.get(cache_key):
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function StubService.get_stub_data refactored with the following changes:

data = cached
else:
data = json.loads(StubService.get_stub_json(service_name, name))
Expand Down
12 changes: 5 additions & 7 deletions fixtures/vsts.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ def _stub_vsts(self):

responses.add(
responses.GET,
"https://app.vssps.visualstudio.com/_apis/accounts?memberId=%s&api-version=4.1"
% self.vsts_user_id,
f"https://app.vssps.visualstudio.com/_apis/accounts?memberId={self.vsts_user_id}&api-version=4.1",
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function VstsIntegrationTestCase._stub_vsts refactored with the following changes:

json={
"count": 1,
"value": [
Expand All @@ -68,12 +67,13 @@ def _stub_vsts(self):
},
)


responses.add(
responses.GET,
"https://app.vssps.visualstudio.com/_apis/resourceareas/79134C72-4A58-4B42-976C-04E7115F32BF?hostId=%s&api-preview=5.0-preview.1"
% self.vsts_account_id,
f"https://app.vssps.visualstudio.com/_apis/resourceareas/79134C72-4A58-4B42-976C-04E7115F32BF?hostId={self.vsts_account_id}&api-preview=5.0-preview.1",
json={"locationUrl": self.vsts_base_url},
)

responses.add(
responses.GET,
"https://app.vssps.visualstudio.com/_apis/profile/profiles/me?api-version=1.0",
Expand Down Expand Up @@ -130,9 +130,7 @@ def _stub_vsts(self):

responses.add(
responses.GET,
"https://{}.visualstudio.com/{}/_apis/wit/workitemtypes/{}/states".format(
self.vsts_account_name.lower(), self.project_a["name"], "Bug"
),
f'https://{self.vsts_account_name.lower()}.visualstudio.com/{self.project_a["name"]}/_apis/wit/workitemtypes/Bug/states',
json={
"value": [
{"name": "resolve_status"},
Expand Down
3 changes: 1 addition & 2 deletions scripts/appconnect_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ def appconnect_config():
for config in symbol_sources:
if config["type"] == "appStoreConnect":
return config
else:
raise KeyError("appStoreConnect config not found")
raise KeyError("appStoreConnect config not found")
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function appconnect_config refactored with the following changes:



if __name__ == "__main__":
Expand Down
3 changes: 1 addition & 2 deletions src/bitfield/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ def __init__(self, flags, default=None, *args, **kwargs):
self.labels = labels

def pre_save(self, instance, add):
value = getattr(instance, self.attname)
return value
return getattr(instance, self.attname)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function BitField.pre_save refactored with the following changes:


def get_prep_value(self, value):
if value is None:
Expand Down
Loading