-
Notifications
You must be signed in to change notification settings - Fork 71
Update packaging guide and repo-review to match spec13 #438
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 all 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 |
|---|---|---|
|
|
@@ -64,10 +64,23 @@ class PY004(General): | |
|
|
||
| @staticmethod | ||
| def check(package: Traversable) -> bool: | ||
| "Projects must have documentation in a folder called docs (disable if not applicable)" | ||
| "Projects must have documentation in a folder called doc or docs (disable if not applicable)" | ||
| return len([p for p in package.iterdir() if "doc" in p.name]) > 0 | ||
|
|
||
|
|
||
| class PY004b(General): | ||
|
Collaborator
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. I don't think a check can end in a letter. I think this could be merged into the PY004 check? Though some projects have multiple
Contributor
Author
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. I think it works :-) One of my main concern was to not mark a project as "not having docs", and think of a plan to convey to projects that
Collaborator
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. Oh, interesting. I feel like I've encoded this somewhere. Maybe not. |
||
| "Documentation folder should be `docs` not `doc`" | ||
|
|
||
| requires = {"PY004"} | ||
|
|
||
| url = mk_url("packaging-simple") | ||
|
|
||
| @staticmethod | ||
| def check(package: Traversable) -> bool: | ||
| "Projects must have documentation in a folder called `docs` not `doc`" | ||
| return any(p.name == "docs" for p in package.iterdir()) | ||
|
|
||
|
|
||
| class PY005(General): | ||
| "Has tests folder" | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -241,5 +241,65 @@ def check(pyproject: dict[str, Any]) -> bool: | |
| return "filterwarnings" in options | ||
|
|
||
|
|
||
| class PP310(PyProject): | ||
| "Tests target is test not test (spec13)" | ||
|
Collaborator
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.
Suggested change
"Tests target is test not test (spec13)"
"Tests extra is `tests` not `test` (spec13)"
? |
||
|
|
||
| requires = {"PP301"} | ||
| url = mk_url("pytest") | ||
|
|
||
| @staticmethod | ||
| def check(pyproject: dict[str, Any]) -> bool | None: | ||
| """ | ||
|
|
||
| Tests target should be `tests` not `test` | ||
|
|
||
| ```toml | ||
| [project.optional-dependencies] | ||
| tests = [ | ||
| 'pytest', | ||
| ... | ||
| ] | ||
| ``` | ||
| """ | ||
| if "tool" not in pyproject: | ||
| return None | ||
| if "project.optional-dependencies" not in pyproject["tool"]: | ||
| return None | ||
| optional_deps = pyproject["tool"]["project.optional-dependencies"] | ||
| if "tests" in optional_deps: | ||
| return True | ||
| return "test" not in optional_deps | ||
|
Comment on lines
+264
to
+271
Collaborator
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.
Suggested change
if "tool" not in pyproject:
return None
if "project.optional-dependencies" not in pyproject["tool"]:
return None
optional_deps = pyproject["tool"]["project.optional-dependencies"]
if "tests" in optional_deps:
return True
return "test" not in optional_deps
match pyproject:
case {"tool": "project" { "optional-dependencies": {"tests": _}}}:
return True
case {"tool": "project" { "optional-dependencies": {"test": _}}}:
return False
case _:
return True
Try pattern matching here. ;)
Contributor
Author
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. Yeah, I need to practice more my pattern matching :-)
Collaborator
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. SPEC 0 should make that easier now. :) |
||
|
|
||
|
|
||
| class PP311(PyProject): | ||
| "Tests target is `docs not` `doc` (spec13)" | ||
|
Collaborator
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.
Suggested change
"Tests target is `docs not` `doc` (spec13)"
"Tests target is `docs` not `doc` (SPEC13)"
|
||
|
|
||
| requires = {"PP301"} | ||
| url = mk_url("pytest") | ||
|
|
||
| @staticmethod | ||
| def check(pyproject: dict[str, Any]) -> bool | None: | ||
| """ | ||
|
|
||
| docs target should be `docs` not `doc` | ||
|
Collaborator
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.
Suggested change
docs target should be `docs` not `doc`
docs extra should be `docs` not `doc`
Collaborator
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. Also, I am not interested in having a check that goes against the official Python packaging specifications, which state https://packaging.python.org/en/latest/specifications/core-metadata/#provides-extra-multiple-use However, given that |
||
|
|
||
| ```toml | ||
| [project.optional-dependencies] | ||
| docs = [ | ||
| 'sphinx', | ||
| ... | ||
| ] | ||
| ``` | ||
| """ | ||
| if "tool" not in pyproject: | ||
| return None | ||
| if "project.optional-dependencies" not in pyproject["tool"]: | ||
| return None | ||
| optional_deps = pyproject["tool"]["project.optional-dependencies"] | ||
| if "docs" in optional_deps: | ||
| return True | ||
| return "doc" not in optional_deps | ||
|
|
||
|
|
||
| def repo_review_checks() -> dict[str, PyProject]: | ||
| return {p.__name__: p() for p in PyProject.__subclasses__()} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,6 +73,6 @@ docs = | |
| sphinx>=7.0 | ||
| sphinx-autodoc-typehints | ||
| sphinx-copybutton | ||
| test = | ||
| tests = | ||
| pytest>=6 | ||
| pytest-cov>=3 | ||