Skip to content
Draft
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
27 changes: 6 additions & 21 deletions agent/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ dependencies = [

[dependency-groups]
dev = [
"black",
"coverage",
"flake8",
"isort",
"pytest",
"pytest-asyncio",
"pytest-cov",
"pytest-xdist",
"ruff",
"tox",
"tox-uv",
"yarl",
Expand All @@ -36,27 +36,12 @@ packages = ["src/balrogagent"]
[project.scripts]
balrogagent = "balrogagent.cmd:main"

[tool.black]
[tool.ruff]
line-length = 160
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unrelated to this PR.. but could we consider lowering this to 100?

target-version = ["py38"]
include = '\.(wsgi|pyi?)$'
exclude = '''
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| \.cache
| \.cache_py3
| _build
| buck-out
| build
| dist
| ui
)/
'''
target-version = "py313"

[tool.ruff.format]
docstring-code-format = true

[tool.isort]
multi_line_output = 3
Expand Down
8 changes: 2 additions & 6 deletions agent/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ parallel_show_output = true
[testenv:check]
skip_install = true
commands =
black --diff --check {toxinidir}
ruff format --diff {toxinidir}
isort --check --diff {toxinidir}
flake8 {toxinidir}
# Doesn't work without a .git directory
Expand All @@ -35,13 +35,9 @@ commands =
max-line-length = 160
exclude = .ropeproject,.tox,sandbox,build
show-source = True
# flake8 doesn't differentiat the use of `:` in dictionaries vs. slices,
# whereas # black formats the a later with surrounding whitespace. This causes
# flake8 to incorrecly report E203.
# See https://black.readthedocs.io/en/stable/the_black_code_style.html#slices
# W503 is a default ignore, but gets overridden when we set this, so we need
# to add it again ourselves.
ignore = E203,W503
ignore = W503

[pytest]
norecursedirs = .tox .git .hg sandbox build
Expand Down
27 changes: 6 additions & 21 deletions client/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ requires-python = ">=3.11"

[dependency-groups]
dev = [
"black",
"coverage",
"flake8",
"flake8-black",
"isort",
"pytest",
"pytest-cov",
"requests_mock",
"ruff",
"tox",
"tox-uv",
]
Expand All @@ -32,26 +31,12 @@ build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel]
packages = ["src/balrogclient"]

[tool.black]
[tool.ruff]
line-length = 160
include = '\.(wsgi|pyi?)$'
exclude = '''
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| \.cache
| \.cache_py3
| _build
| buck-out
| build
| dist
| ui
)/
'''
target-version = "py311"

[tool.ruff.format]
docstring-code-format = true

[tool.isort]
multi_line_output = 3
Expand Down
8 changes: 2 additions & 6 deletions client/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,17 @@ parallel_show_output = true

[testenv:check]
commands =
black --diff --check {toxinidir}
ruff format --diff {toxinidir}
isort --check --diff {toxinidir}
flake8 {toxinidir}

[flake8]
max-line-length = 160
exclude = .ropeproject,.tox,sandbox,build,.venv
show-source = True
# flake8 doesn't differentiat the use of `:` in dictionaries vs. slices,
# whereas # black formats the a later with surrounding whitespace. This causes
# flake8 to incorrecly report E203.
# See https://black.readthedocs.io/en/stable/the_black_code_style.html#slices
# W503 is a default ignore, but gets overridden when we set this, so we need
# to add it again ourselves.
ignore = E203,W503
ignore = W503

[pytest]
norecursedirs = .tox .git .hg sandbox build
Expand Down
145 changes: 27 additions & 118 deletions client/uv.lock

Large diffs are not rendered by default.

30 changes: 7 additions & 23 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,10 @@ members = [

[dependency-groups]
dev = [
# held back due to https://github.com/psf/black/issues/4963
"black<26.1.0",
"coverage",
"coveralls",
"fakeredis",
"flake8",
"flake8-black",
# https://github.com/HypothesisWorks/hypothesis/issues/4638
"hypothesis<6.150.0",
"isort",
Expand All @@ -65,6 +62,7 @@ dev = [
"pytest-cov",
"pytest-responses",
"pytest-xdist",
"ruff",
"tox",
"tox-uv",
]
Expand All @@ -81,27 +79,13 @@ build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel]
packages = ["src/auslib"]

[tool.black]
[tool.ruff]
line-length = 160
target-version = ["py38"]
include = '\.(wsgi|pyi?)$'
exclude = '''
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| \.cache
| \.cache_py3
| _build
| buck-out
| build
| dist
| ui
)/
'''
target-version = "py313"
extend-exclude = ["ui"]

[tool.ruff.format]
docstring-code-format = true

[tool.isort]
multi_line_output = 3
Expand Down
28 changes: 14 additions & 14 deletions scripts/adhoc-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def make_url(self, environment, interface, append):
def version(self, environment, interface):
url = self.make_url(environment, interface, "__version__")
version = self.balrog_request("GET", url, headers=self.headers)
log.info(f' {environment}-{interface} version: {version["version"]}')
log.info(f" {environment}-{interface} version: {version['version']}")

def heartbeat(self, environment, interface):
url = self.make_url(environment, interface, "__heartbeat__")
Expand All @@ -92,35 +92,35 @@ def heartbeat(self, environment, interface):
def admin_releases(self, environment, interface):
url = self.make_url(environment, interface, "releases")
releases = self.balrog_request("GET", url, headers=self.headers)
log.info(f' {len(releases["releases"])} releases found')
log.info(f" {len(releases['releases'])} releases found")
url = self.make_url(environment, interface, "api/releases")
releases = self.balrog_request("GET", url, headers=self.headers)
log.info(f' {len(releases["releases"])} api/releases found')
log.info(f" {len(releases['releases'])} api/releases found")
url = self.make_url(environment, interface, "api/v2/releases")
releases = self.balrog_request("GET", url, headers=self.headers)
log.info(f' {len(releases["releases"])} api/v2/releases found')
log.info(f" {len(releases['releases'])} api/v2/releases found")
if test_level > 2:
for r in releases["releases"][-10:]:
log.info(f'{r["name"]} ({r["product"]}, {r["data_version"]})')
url = self.make_url(environment, interface, f'api/v2/releases/{r["name"]}')
log.info(f"{r['name']} ({r['product']}, {r['data_version']})")
url = self.make_url(environment, interface, f"api/v2/releases/{r['name']}")
self.balrog_request("GET", url, headers=self.headers)

def admin_scheduled_changes(self, environment, interface):
url = self.make_url(environment, interface, "scheduled_changes/emergency_shutoff")
resp = self.balrog_request("GET", url, headers=self.headers)
log.info(f' {resp["count"]} scheduled changes')
log.info(f" {resp['count']} scheduled changes")
url = self.make_url(environment, interface, "scheduled_changes/required_signoffs/permissions")
resp = self.balrog_request("GET", url, headers=self.headers)
log.info(f' {resp["count"]} scheduled changes')
log.info(f" {resp['count']} scheduled changes")
url = self.make_url(environment, interface, "scheduled_changes/required_signoffs/product")
resp = self.balrog_request("GET", url, headers=self.headers)
log.info(f' {resp["count"]} scheduled changes')
log.info(f" {resp['count']} scheduled changes")
url = self.make_url(environment, interface, "scheduled_changes/releases")
resp = self.balrog_request("GET", url, headers=self.headers)
log.info(f' {resp["count"]} scheduled changes')
log.info(f" {resp['count']} scheduled changes")
url = self.make_url(environment, interface, "scheduled_changes/rules")
resp = self.balrog_request("GET", url, headers=self.headers)
log.info(f' {resp["count"]} scheduled changes')
log.info(f" {resp['count']} scheduled changes")

def public_updates(self, environment, interface):
# TODO many other interesting and important endpoints
Expand All @@ -135,14 +135,14 @@ def public_updates(self, environment, interface):
def public_releases(self, environment, interface):
url = self.make_url(environment, interface, "api/v1/releases")
releases = self.balrog_request("GET", url, headers=self.headers)
log.info(f' {len(releases["releases"])} api/v1/releases found')
log.info(f" {len(releases['releases'])} api/v1/releases found")
url = self.make_url(environment, interface, "api/v1/releases?name_prefix=Firefox")
releases = self.balrog_request("GET", url, headers=self.headers)
log.info(f' {len(releases["releases"])} api/v1/releases starting with "Firefox" found')
if test_level > 2:
for r in releases["releases"][-10:]:
log.info(f'{r["name"]} ({r["product"]}, {r["data_version"]})')
url = self.make_url(environment, interface, f'api/v1/releases/{r["name"]}')
log.info(f"{r['name']} ({r['product']}, {r['data_version']})")
url = self.make_url(environment, interface, f"api/v1/releases/{r['name']}")
self.balrog_request("GET", url, headers=self.headers)

def run_tests_admin(self):
Expand Down
2 changes: 1 addition & 1 deletion scripts/get-prod-db-dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def setLocalDBPermissions():
try:
rsp = urlopen(HOST + PATH, timeout=TIMEOUT)
except (HTTPError, URLError) as e:
logging.debug("Downloading the latest database dump failed" "due to network error: %s", e)
logging.debug("Downloading the latest database dump faileddue to network error: %s", e)
exit(1)

with open(LOCAL_DB_PATH, "wb") as f:
Expand Down
4 changes: 1 addition & 3 deletions src/auslib/util/jsonschema_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ def version_validator(field_value):
try:
op, operand = get_op(rule_version)
if is_list_of_versions and op != operator.eq:
raise jsonschema.ValidationError(
"Invalid input for %s .Relational Operators are not allowed" " when providing a list of versions." % field_value
)
raise jsonschema.ValidationError("Invalid input for %s .Relational Operators are not allowed when providing a list of versions." % field_value)
version = MozillaVersion(operand)
except jsonschema.ValidationError:
raise
Expand Down
10 changes: 5 additions & 5 deletions src/auslib/web/admin/views/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def get_user_permission(username, permission, changed_by):
try:
perm = dbo.permissions.getUserPermissions(username, changed_by)[permission]
except KeyError:
return problem(404, "Not Found", "Requested user permission" " %s not found for %s" % (permission, username))
return problem(404, "Not Found", "Requested user permission %s not found for %s" % (permission, username))
return jsonify(perm)


Expand Down Expand Up @@ -89,7 +89,7 @@ def ensure_user_permission(username, permission, user_permission_request_body, c
@transactionHandler
def update_user_permission(username, permission, user_permission_request_body, changed_by, transaction):
if not dbo.permissions.getUserPermissions(username, changed_by, transaction=transaction).get(permission):
return problem(status=404, title="Not Found", detail="Requested user permission" " %s not found for %s" % (permission, username))
return problem(status=404, title="Not Found", detail="Requested user permission %s not found for %s" % (permission, username))
try:
# Existing Permission
if not user_permission_request_body.get("data_version"):
Expand Down Expand Up @@ -118,7 +118,7 @@ def update_user_permission(username, permission, user_permission_request_body, c
@transactionHandler
def delete_user_permission(username, permission, data_version, changed_by, transaction):
if not dbo.permissions.getUserPermissions(username, changed_by, transaction=transaction).get(permission):
return problem(404, "Not Found", "Requested user permission" " %s not found for %s" % (permission, username))
return problem(404, "Not Found", "Requested user permission %s not found for %s" % (permission, username))
try:
# For practical purposes, DELETE can't have a request body, which means the Form
# won't find data where it's expecting it. Instead, we have to tell it to look at
Expand All @@ -141,7 +141,7 @@ def get_scheduled_changes():
@transactionHandler
def schedule_change(sc_permission_body, transaction, changed_by):
if sc_permission_body.get("when", None) is None:
return problem(400, "Bad Request", "'when' cannot be set to null when scheduling a new change " "for a Permission")
return problem(400, "Bad Request", "'when' cannot be set to null when scheduling a new change for a Permission")
change_type = sc_permission_body.get("change_type")

what = sc_permission_body
Expand Down Expand Up @@ -267,7 +267,7 @@ def grant_role(username, role, changed_by, transaction):
def revoke_role(username, role, data_version, changed_by, transaction):
roles = [r["role"] for r in dbo.permissions.getUserRoles(username)]
if role not in roles:
return problem(404, "Not Found", "Role not found", ext={"exception": "No role '%s' found for " "username '%s'" % (role, username)})
return problem(404, "Not Found", "Role not found", ext={"exception": "No role '%s' found for username '%s'" % (role, username)})
# query argument i.e. data_version is also required.
# All input value validations already defined in swagger specification and carried out by connexion
dbo.permissions.revokeRole(username, role, changed_by=changed_by, old_data_version=data_version, transaction=transaction)
Expand Down
4 changes: 2 additions & 2 deletions src/auslib/web/admin/views/releases.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def changeRelease(release, changed_by, transaction, existsCallback, commitCallba
log.warning("Bad input: %s", rel)
return problem(400, "Bad Request", msg)
if "hashFunction" in releaseInfo["data"] and hashFunction and hashFunction != releaseInfo["data"]["hashFunction"]:
msg = "hashFunction '{0}' doesn't match the one on the release " "object ('{1}') for release '{2}'".format(
msg = "hashFunction '{0}' doesn't match the one on the release object ('{1}') for release '{2}'".format(
hashFunction, releaseInfo["data"]["hashFunction"], rel
)
log.warning("Bad input: %s", rel)
Expand Down Expand Up @@ -418,7 +418,7 @@ def get_scheduled_changes():
def create_scheduled_change(sc_release_body, transaction, changed_by):
what = sc_release_body
if what.get("when", None) is None:
return problem(400, "Bad Request", "'when' cannot be set to null when scheduling a new change " "for a Release")
return problem(400, "Bad Request", "'when' cannot be set to null when scheduling a new change for a Release")
change_type = what.get("change_type")

if change_type == "update":
Expand Down
6 changes: 3 additions & 3 deletions src/auslib/web/admin/views/required_signoffs.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def product_get_scheduled_changes():
@transactionHandler
def product_create_scheduled_change(sc_rs_product_body, transaction, changed_by):
if sc_rs_product_body.get("when", None) is None:
return problem(400, "Bad Request", "when cannot be set to null when scheduling a new change " "for a Product Required Signoff")
return problem(400, "Bad Request", "when cannot be set to null when scheduling a new change for a Product Required Signoff")
change_type = sc_rs_product_body.get("change_type")

what = {}
Expand Down Expand Up @@ -308,7 +308,7 @@ def permissions_get_scheduled_changes():
@transactionHandler
def permissions_create_scheduled_change(sc_rs_permission_body, transaction, changed_by):
if sc_rs_permission_body.get("when", None) is None:
return problem(400, "Bad Request", "'when' cannot be set to null when scheduling a new change " "for a Permissions Required Signoff")
return problem(400, "Bad Request", "'when' cannot be set to null when scheduling a new change for a Permissions Required Signoff")
change_type = sc_rs_permission_body.get("change_type")

what = {}
Expand Down Expand Up @@ -350,7 +350,7 @@ def permissions_update_scheduled_change(sc_id, sc_permission_rs_body, transactio
if sc_rs_permission:
change_type = sc_rs_permission[0]["change_type"]
else:
return problem(404, "Not Found", "Unknown sc_id", ext={"exception": "No scheduled change for permission required " "signoff found for given sc_id"})
return problem(404, "Not Found", "Unknown sc_id", ext={"exception": "No scheduled change for permission required signoff found for given sc_id"})
what = {}
for field in sc_permission_rs_body:
if (
Expand Down
Loading