-
Notifications
You must be signed in to change notification settings - Fork 0
chore: enforce python docstring coverage #41
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| """Package desktop build outputs into traceable release artifacts.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from pathlib import Path | ||
|
|
@@ -8,6 +10,7 @@ | |
|
|
||
|
|
||
| def sha256_file(path: Path) -> str: | ||
| """Return the SHA-256 digest for a file.""" | ||
| digest = hashlib.sha256() | ||
| with path.open("rb") as handle: | ||
| for chunk in iter(lambda: handle.read(1024 * 1024), b""): | ||
|
|
@@ -16,6 +19,7 @@ def sha256_file(path: Path) -> str: | |
|
|
||
|
|
||
| def normalized_platform() -> str: | ||
| """Return the normalized artifact platform label for the current environment.""" | ||
| if artifact_platform := os.environ.get("BANDSCOPE_ARTIFACT_OS"): | ||
| return artifact_platform | ||
|
|
||
|
|
@@ -27,6 +31,7 @@ def normalized_platform() -> str: | |
|
|
||
|
|
||
| def normalized_architecture() -> str: | ||
| """Return the normalized artifact architecture label for the current environment.""" | ||
| if artifact_arch := os.environ.get("BANDSCOPE_ARTIFACT_ARCH"): | ||
| return artifact_arch | ||
|
|
||
|
|
@@ -40,6 +45,7 @@ def normalized_architecture() -> str: | |
|
|
||
|
|
||
| def artifact_identity() -> dict[str, str]: | ||
| """Build the archive and manifest names for the current artifact target.""" | ||
| git_sha = os.environ.get("GITHUB_SHA", "local")[:12] | ||
| target_platform = normalized_platform() | ||
| target_arch = normalized_architecture() | ||
|
|
@@ -53,17 +59,25 @@ def artifact_identity() -> dict[str, str]: | |
|
|
||
|
|
||
| def expected_binary_path(repo_root: Path) -> Path: | ||
| system = normalized_platform() | ||
| """Return the expected desktop binary path for the selected target triple.""" | ||
| target_triple = os.environ.get("BANDSCOPE_TARGET_TRIPLE") | ||
| if target_triple and "windows" in target_triple: | ||
| system = "windows" | ||
| elif target_triple and "apple-darwin" in target_triple: | ||
| system = "macos" | ||
| else: | ||
| system = normalized_platform() | ||
| binary_name = ( | ||
| "bandscope-desktop.exe" if system == "windows" else "bandscope-desktop" | ||
| ) | ||
| target_root = repo_root / "apps" / "desktop" / "src-tauri" / "target" | ||
| if target_triple := os.environ.get("BANDSCOPE_TARGET_TRIPLE"): | ||
| if target_triple: | ||
| target_root = target_root / target_triple | ||
| return target_root / "release" / binary_name | ||
|
Comment on lines
61
to
76
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
์ฌ๊ธฐ์๋ target triple๋ก ๋ฐ์ด๋๋ฆฌ ๊ฒฝ๋ก์ ํ์ฅ์๋ฅผ ์ผ๋ถ ๋ฎ์ด์ฐ์ง๋ง, ๐ค Prompt for AI Agents |
||
|
|
||
|
|
||
| def main() -> int: | ||
| """Package the desktop binary, frontend assets, and metadata into a zip archive.""" | ||
| repo_root = Path(__file__).resolve().parents[2] | ||
| binary_path = expected_binary_path(repo_root) | ||
| frontend_dist = repo_root / "apps" / "desktop" / "dist" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๐งฉ Analysis chain
๐ Web query:
What do Ruff pydocstyle rules D100-D107 cover? Do they apply only to public modules/classes/functions/methods, or also private underscore-prefixed ones?๐ก Result:
Ruffโs pydocstyle D100โD107 rules are the โmissing docstringโ checks:
__init__.py) (pydocstyle.readthedocs.io)__str__) (pydocstyle.readthedocs.io)__init__(pydocstyle.readthedocs.io)Do they apply to private (underscore-prefixed) definitions?
For D100โD104 and D106, they apply only to public constructs. In pydocstyle (which Ruff derives these from), a construct is public only if its parent is public and its name does not start with
_or__(with the special case that names like__init__.pyare treated as public for this purpose). Also, if__all__is defined, only names listed there are considered public. (pydocstyle.readthedocs.io)So, e.g.
_foo()/_Bar/_baz.pywonโt trigger D1xx โmissing docstringโ errors just because they lack docstrings. (pydocstyle.readthedocs.io)D105 is different: it targets magic methods (dunders), not โpublic vs privateโ by underscore prefix. (pydocstyle.readthedocs.io)
Citations:
D100-D107 ๊ท์น๋ง์ผ๋ก๋ "100% docstring coverage"๋ฅผ ์ค์ ๋ก ๊ฐ์ ํ์ง ๋ชปํฉ๋๋ค.
ํ์ฌ ์ ํํ Ruff ๊ท์น์ public ์ฌ๋ณผ๋ง์ ๋์์ผ๋ก ํฉ๋๋ค. ๋ฐ๋ผ์
_helper()๊ฐ์ private ํจ์๋_PrivateClass๊ฐ์ private ํด๋์ค๋ docstring ๊ฒ์ฌ ๋์์์ ์ ์ธ๋์ด ํต๊ณผํฉ๋๋ค. PR์ ๋ชฉํ์ARCHITECTURE.md์์ ๋ช ์ํ "100% docstring coverage" ์ ์ฑ ์ ์ผ์น์ํค๋ ค๋ฉด, ์ ์ฑ ๋ฌธ๊ตฌ๋ฅผ public ๋ฒ์๋ก ๋ช ํํ ์ขํ๊ฑฐ๋ private ์ฌ๋ณผ๊น์ง ํฌํจํ๋ ์ถ๊ฐ ๊ฒ์ฌ๋ฅผ ๋์ ํด์ผ ํฉ๋๋ค.