Skip to content

Commit

Permalink
Add back alls to ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonxslays committed Feb 2, 2024
1 parent 84936be commit 1ed994a
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
strategy:
fail-fast: false
matrix:
session: [types, formatting, imports]
session: [types, formatting, imports, alls]
runs-on: ubuntu-latest

steps:
Expand Down
6 changes: 6 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,9 @@ def imports(session: nox.Session) -> None:
"--extend-exclude",
"__init__.py",
)


@nox.session(reuse_venv=True)
def alls(session: nox.Session) -> None:
session.install(".")
session.run("python", "scripts/alls.py")
52 changes: 52 additions & 0 deletions scripts/alls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import sys
import typing as t

import unkey


_IGNORE = ("annotations", "protected")


def should_include_module(module: str) -> bool:
if module in _IGNORE:
return False

if (char := module[0]) == "_":
return False

if char.upper() == char:
return False

return True


def get_modules() -> t.List[str]:
return [m for m in unkey.__dict__ if should_include_module(m)]


def get_alls() -> t.Tuple[t.Set[str], t.Set[str]]:
modules = get_modules()
return (
set(item for module in modules for item in unkey.__dict__[module].__all__),
set(i for i in unkey.__all__ if i not in modules),
)


def validate_alls() -> None:
modules, lib = get_alls()
err = None

if missing := modules - lib:
err = "Missing exported items at top level:\n" + "\n".join(f" - {m}" for m in missing)
print(err, file=sys.stderr)

if missing := lib - modules:
err = "Missing exported items at module level:\n" + "\n".join(f" - {m}" for m in missing)
print(err, file=sys.stderr)

if err:
sys.exit(1)


if __name__ == "__main__":
validate_alls()

0 comments on commit 1ed994a

Please sign in to comment.