Skip to content

refactor(bench): Type hint bench api#6185

Open
Aradhya-Tripathi wants to merge 11 commits into
developfrom
typehint-bench
Open

refactor(bench): Type hint bench api#6185
Aradhya-Tripathi wants to merge 11 commits into
developfrom
typehint-bench

Conversation

@Aradhya-Tripathi
Copy link
Copy Markdown
Contributor

@Aradhya-Tripathi Aradhya-Tripathi commented Apr 20, 2026

Ref: #5973

Things Removed

  • Bench dependency control getting/updating bench dependency is no longer managed by the API instead it has been moved to the controller doctype.

@dashboard_whitelist()
def update_dependency(self, dependency_name: str, version: str, is_custom: bool):
"""Updates a dependency version in the Release Group Dependency table"""
for dependency in self.dependencies:
if dependency.name == dependency_name:
dependency.version = version
dependency.is_custom = is_custom
self.save()
return

https://github.com/frappe/press/blob/694c0583c421be85c9e62c266246dd51db36913e/press/press/doctype/release_group_dependency/release_group_dependency.py#L27-L48

  • Bench config (+ site config)
    @dashboard_whitelist()
    def update_config(self, config):
    sanitized_common_site_config = [
    {"key": c.key, "type": c.type, "value": c.value} for c in self.common_site_config_table
    ]
    sanitized_bench_config = []
    bench_config_keys = ["http_timeout"]
    config = frappe.parse_json(config)
    for key, value in config.items():
    if key in get_client_blacklisted_keys():
    frappe.throw(_(f"The key <b>{key}</b> is blacklisted or is internal and cannot be updated"))
    config_type = get_config_type(value)
    if frappe.db.exists("Site Config Key", key):
    config_type = frappe.db.get_value("Site Config Key", key, "type")
    value = get_formatted_config_value(
    config_type,
    value,
    key,
    self.name,
    )
    if key in bench_config_keys:
    sanitized_bench_config.append({"key": key, "value": value, "type": config_type})
    # update existing key
    for row in sanitized_common_site_config:
    if row["key"] == key:
    row["value"] = value
    row["type"] = config_type
    break
    else:
    sanitized_common_site_config.append({"key": key, "value": value, "type": config_type})
    self.update_config_in_release_group(sanitized_common_site_config, sanitized_bench_config)
    self.update_benches_config()

    @dashboard_whitelist()
    def delete_config(self, key):
    """Deletes a key from the common_site_config_table"""
    if key in get_client_blacklisted_keys():
    return
    updated_common_site_config = []
    for row in self.common_site_config_table:
    if row.key != key and not row.internal:
    updated_common_site_config.append({"key": row.key, "value": row.value, "type": row.type})
    # using a tuple to avoid updating bench_config
    # TODO: remove tuple when bench_config is removed and field for http_timeout is added
    self.update_config_in_release_group(updated_common_site_config, ())

Removed related tests as well.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

❌ Patch coverage is 79.69925% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.10%. Comparing base (d370a30) to head (d42241e).
⚠️ Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
press/api/bench.py 79.69% 27 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           develop    #6185       +/-   ##
============================================
- Coverage    90.75%   49.10%   -41.66%     
============================================
  Files          109      908      +799     
  Lines        17234    75264    +58030     
  Branches       515      350      -165     
============================================
+ Hits         15641    36956    +21315     
- Misses        1566    38284    +36718     
+ Partials        27       24        -3     
Flag Coverage Δ
dashboard 61.02% <ø> (-29.74%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant