-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More comments and stuff WIP Fix more tests Remove top-level symbols. Move more stuff Pre-commit fix constants/tests Fix install commands and builder group Manage poetry extras Isolate base, cleanup trash
- Loading branch information
1 parent
26193f7
commit 3c9d7dc
Showing
227 changed files
with
943 additions
and
938 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#! /bin/bash | ||
poetry install | ||
poetry install --with=dev,dev-server --extras=all | ||
poetry run pre-commit install | ||
git lfs install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# type: ignore # tomlkit APIs are messy. | ||
import collections | ||
import pathlib | ||
from typing import DefaultDict, Set | ||
|
||
import tomlkit | ||
|
||
|
||
def _populate_extras(pyproject_path: pathlib.Path) -> None: | ||
with pyproject_path.open("r", encoding="utf-8") as file: | ||
original_content = file.read() | ||
content = tomlkit.parse(original_content) | ||
|
||
dependencies = content["tool"]["poetry"]["dependencies"] | ||
dependency_metadata = content["tool"]["dependency_metadata"] | ||
|
||
extra_sections: DefaultDict[str, Set[str]] = collections.defaultdict(set) | ||
all_deps: Set[str] = set() | ||
|
||
for key, value in dependencies.items(): | ||
if isinstance(value, dict): | ||
is_optional = value.get("optional", False) | ||
else: | ||
is_optional = False # Base dependencies. | ||
|
||
if not is_optional: | ||
continue | ||
|
||
if key not in dependency_metadata: | ||
raise ValueError( | ||
f"`{key}` is missing in `[tool.dependency_metadata]`. " | ||
f"(file: {pyproject_path}). Please add metadata." | ||
) | ||
metadata = dependency_metadata[key] | ||
components = metadata["components"].split(",") | ||
for component in components: | ||
if component == "base": | ||
continue | ||
extra_sections[component].add(key) | ||
all_deps.add(key) | ||
|
||
for key in dependency_metadata.keys(): | ||
if key not in dependencies: | ||
raise ValueError( | ||
f"`{key}` in `[tool.dependency_metadata]` is not in " | ||
"`[tool.poetry.dependencies]`. " | ||
f"(file: {pyproject_path}). Please remove or sync." | ||
) | ||
|
||
extras_section = tomlkit.table() | ||
for extra_section, deps in extra_sections.items(): | ||
extras_section[extra_section] = tomlkit.array() | ||
extras_section[extra_section].extend(sorted(deps)) | ||
|
||
extras_section["all"] = tomlkit.array() | ||
extras_section["all"].extend(sorted(all_deps)) | ||
|
||
if "extras" not in content["tool"]["poetry"]: | ||
raise ValueError("Expected section [tool.poetry.extras] to be present.") | ||
|
||
content["tool"]["poetry"]["extras"] = extras_section | ||
|
||
updated_content = tomlkit.dumps(content) | ||
|
||
# Compare the content before and after; if changes were made, fail the check | ||
if original_content != updated_content: | ||
with pyproject_path.open("w", encoding="utf-8") as file: | ||
file.write(updated_content) | ||
print(f"File '{pyproject_path}' was updated. Please re-stage the changes.") | ||
exit(1) | ||
|
||
print("No changes detected.") | ||
|
||
|
||
if __name__ == "__main__": | ||
pyproject_file = pathlib.Path(__file__).parent.parent.resolve() / "pyproject.toml" | ||
_populate_extras(pyproject_file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.