Skip to content

refactor(api): enable strict typing for workspace permission tests - #43875

Merged
asukaminato0721 merged 1 commit into
langgenius:mainfrom
CodeAlex52:refactor/api-strict-typing-workspace-permission-tests
Oct 11, 2026
Merged

asukaminato0721 merged 1 commit into
langgenius:mainfrom
CodeAlex52:refactor/api-strict-typing-workspace-permission-tests

Conversation

@CodeAlex52

Copy link
Copy Markdown
Contributor

Summary

Part of #24645, following #43798 / #43840.

libs/test_workspace_permission.py (tests for the workspace member-invite and owner-transfer permission helpers) was excluded from strict Pyrefly checks as strict-mode debt, and reported 23 strict diagnostics — 8 unannotated returns and 15 implicit-any parameters. This brings the file under strict checking so future typing regressions are caught.

This covers this one test file only. No production code changes, and no test logic or assertions change.

What changed

  • Annotate the @patch-injected mock_enterprise_service parameters as Mock.
  • Annotate the config_overrides parameters as Callable[..., None], the type the root tests/unit_tests/conftest.py fixture returns (same as refactor(api): enable strict typing for cached embedding tests #43798).
  • Add -> None return annotations to the eight test methods.
  • Remove the file from the unit-test Pyrefly exclusions.

Verification

  • pyrefly check --config=tests/unit_tests/pyrefly.toml --use-ignore-files=false --disable-project-excludes-heuristics=true tests/unit_tests/libs/test_workspace_permission.py (from api/): 23 diagnostics before the change, zero after.
  • pyrefly check --config=tests/unit_tests/pyrefly.toml over the whole unit-test project: passed.
  • ./dev/pyrefly-check-local (backend make type-check): passed.
  • uv run --dev pytest tests/unit_tests/libs/test_workspace_permission.py: 8 passed.
  • ruff format and ruff check on the file: passed.
  • lint-imports: 64 contracts kept, 0 broken.
  • scripts/check_no_spec_mock.py on the file: passed.
  • scripts/check_no_new_getattr.py, check_no_new_controller_sqlalchemy.py, check_no_new_session_mock.py with --base-rev origin/main: passed.

Screenshots

Before After
N/A: test and type-check configuration only; 23 strict diagnostics. N/A: zero strict diagnostics; file included in strict type checks.

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've verified the change and added or updated tests where meaningful regression risk justifies coverage.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and vp staged (frontend) to appease the lint gods (backend only: ran the underlying ruff, import-linter, guard-script and Pyrefly commands listed above)

From OpenCode

@github-actions github-actions Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Oct 11, 2026
@ghfind-review ghfind-review Bot added the review: medium ghfind author score; see https://ghfind.com label Oct 11, 2026
@asukaminato0721 asukaminato0721 self-assigned this Oct 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 72.15% 72.18% +0.03%
Strict coverage 71.81% 71.84% +0.03%
Typed symbols 58,230 58,253 +23
Untyped symbols 22,584 22,561 -23
Modules 3738 3738 0

@codecov

codecov Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.82%. Comparing base (5a8dd14) to head (d0ea2fc).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #43875   +/-   ##
=======================================
  Coverage   88.81%   88.82%           
=======================================
  Files        5319     5319           
  Lines      329278   329278           
  Branches    65994    65994           
=======================================
+ Hits       292454   292466   +12     
+ Misses      31596    31583   -13     
- Partials     5228     5229    +1     
Flag Coverage Δ
api 88.42% <ø> (+<0.01%) ⬆️

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

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

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@asukaminato0721
asukaminato0721 added this pull request to the merge queue Oct 11, 2026
Merged via the queue into langgenius:main with commit 7c24bd0 Oct 11, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review: medium ghfind author score; see https://ghfind.com size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants