Skip to content

Commit

Permalink
working with uv (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
carderne authored Sep 3, 2024
1 parent 70bf993 commit 4558efe
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 88 deletions.
2 changes: 1 addition & 1 deletion plugins/hatch/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ classifiers = [
"Programming Language :: Python :: 3.12",
]

dependencies = ["hatchling"]
dependencies = ["hatchling >= 1.25.0"]

[project.urls]
homepage = "https://github.com/carderne/una"
Expand Down
25 changes: 16 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
[project]
name = "una"
version = "0.0"
requires-python = ">= 3.11"
name = "una-root"
version = "0"
requires-python = ">=3.11"
dependencies = ["una", "hatch-una"]

[tool.uv]
dev-dependencies = []
dev-dependencies = [
"pytest >= 8.3.1",
"basedpyright >= 1.15.2",
"mkdocs-material >= 9.5.31",
"ruff >= 0.6.2",
]
package = false

[tool.uv.sources]
una = { workspace = true }
hatch-una = { workspace = true }

[tool.uv.workspace]
members = ["una", "plugins/hatch"]

Expand All @@ -25,12 +35,9 @@ known-first-party = ["una"]
venvPath = "."
venv = ".venv"
pythonVersion = "3.11"
strict = ["**/*.py"]
extraPaths = ["plugins/hatch"]
strict = ["una/**/*.py", "plugins/**/*.py"]
ignore = ["dist/"]
reportUnnecessaryTypeIgnoreComment = true
reportImplicitOverride = false
reportUnusedCallResult = false
enableTypeIgnoreComments = true

[tool.pytest.ini_options]
addopts = "-sv"
2 changes: 1 addition & 1 deletion tests/test_distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def __init__(self, name: str, data: str):
self.data = data
self.metadata = {"name": name}

def read_text(self, *args: object) -> str:
def read_text(self, *_: object) -> str:
return self.data


Expand Down
8 changes: 1 addition & 7 deletions una/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@ repository = "https://github.com/carderne/una"
una = "una.cli:app"

[tool.uv]
dev-dependencies = [
"pytest >= 8.3.1",
"basedpyright >= 1.15.2",
"mkdocs-material >= 9.5.31",
"ruff >= 0.6.2",
]
dev-dependencies = []

[build-system]
requires = ["hatchling", "hatch-vcs"]
Expand All @@ -59,7 +54,6 @@ venvPath = ".."
venv = ".venv"
pythonVersion = "3.11"
strict = ["**/*.py"]
extraPaths = ["plugins/hatch"]
reportUnnecessaryTypeIgnoreComment = true
reportImplicitOverride = false
reportUnusedCallResult = false
Expand Down
4 changes: 2 additions & 2 deletions una/una/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def sync_command(
ns = config.get_ns(root)
alias_list = alias.split(",") if alias else []

packages = package_deps.get_packages(root, ns)
packages = package_deps.get_packages(root)
diffs: list[CheckDiff] = []
for p in packages:
d = check.check_package_deps(root, ns, p, alias_list)
Expand All @@ -56,7 +56,7 @@ def sync_command(
raise Exit()

for d in diffs:
sync.sync_package(root, d, ns)
sync.sync_package(d)
if not quiet:
for c in d.int_dep_diff:
console.print(f"[pkg]{d.package.name}[/] adding dep [dep]{c}[/]")
Expand Down
6 changes: 3 additions & 3 deletions una/una/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_import():


def create_workspace(path: Path) -> None:
ns = _update_root_pyproj(path, _EXAMPLE_IMPORT)
ns = _update_root_pyproj(path)

app_content = _EXAMPLE_APP_CODE.format(ns=ns, lib_name=_EXAMPLE_LIB_NAME)
app_deps = _EXAMPLE_INTERNAL_DEPS.format(dep_name=_EXAMPLE_LIB_NAME)
Expand Down Expand Up @@ -145,14 +145,14 @@ def _create_dir(path: Path, dir_name: str, keep: bool = False) -> Path:
return d


def _update_root_pyproj(path: Path, dependencies: str) -> str:
def _update_root_pyproj(path: Path) -> str:
pyproj = path / consts.PYPROJ_FILE
with pyproj.open() as f:
toml = tomlkit.parse(f.read())

ns: str = toml["project"]["name"] # pyright:ignore[reportIndexIssue,reportAssignmentType]
requires_python: str = toml["project"]["requires-python"] # pyright:ignore[reportIndexIssue,reportAssignmentType]
toml["tool"]["uv"].add("package", False) # pyright:ignore[reportUnknownMemberType]
toml["tool"]["uv"].add("package", False) # pyright:ignore[reportUnknownMemberType,reportIndexIssue,reportAttributeAccessIssue,reportArgumentType]
toml["tool"]["uv"]["workspace"] = {"members": _EXAMPLE_MEMBERS} # pyright:ignore[reportIndexIssue]
toml["tool"]["una"] = {"namespace": ns, "requires-python": requires_python} # pyright:ignore[reportIndexIssue]
with pyproj.open("w") as f:
Expand Down
2 changes: 1 addition & 1 deletion una/una/package_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from una.types import ConfWrapper, ExtDep, IntDep, PackageDeps


def get_packages(root: Path, ns: str) -> list[PackageDeps]:
def get_packages(root: Path) -> list[PackageDeps]:
confs = get_package_confs(root)
packages = [_get_package_deps(c) for c in confs if Path.cwd().name in c.path.as_posix()]
return packages
Expand Down
2 changes: 1 addition & 1 deletion una/una/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from una.types import CheckDiff, Conf, UvSourceIsWorkspace


def sync_package(root: Path, diff: CheckDiff, ns: str):
def sync_package(diff: CheckDiff):
_rewrite_package_pyproj(diff.package.path, diff.int_dep_diff)


Expand Down
Loading

0 comments on commit 4558efe

Please sign in to comment.