Skip to content

Commit fe734d1

Browse files
dimblebyradoering
authored andcommitted
PyProjectTOML.file -> PyProjectTOML.path
1 parent cefee69 commit fe734d1

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/poetry/core/poetry.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def pyproject(self) -> PyProjectTOML:
3030

3131
@property
3232
def pyproject_path(self) -> Path:
33-
return self._pyproject.file
33+
return self._pyproject.path
3434

3535
@property
3636
def package(self) -> ProjectPackage:

src/poetry/core/pyproject/toml.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
11
from __future__ import annotations
22

33
from contextlib import suppress
4-
from pathlib import Path
4+
from typing import TYPE_CHECKING
55
from typing import Any
66

77
from poetry.core.pyproject.tables import BuildSystem
88
from poetry.core.utils._compat import tomllib
99

1010

11+
if TYPE_CHECKING:
12+
from pathlib import Path
13+
14+
1115
class PyProjectTOML:
12-
def __init__(self, path: str | Path) -> None:
13-
self._file = path if isinstance(path, Path) else Path(path)
16+
def __init__(self, path: Path) -> None:
17+
self._file = path
1418
self._data: dict[str, Any] | None = None
1519
self._build_system: BuildSystem | None = None
1620

1721
@property
18-
def file(self) -> Path:
22+
def path(self) -> Path:
1923
return self._file
2024

2125
@property
2226
def data(self) -> dict[str, Any]:
2327
if self._data is None:
24-
if not self.file.exists():
28+
if not self.path.exists():
2529
self._data = {}
2630
else:
27-
with self.file.open("rb") as f:
31+
with self.path.open("rb") as f:
2832
self._data = tomllib.load(f)
2933

3034
return self._data
@@ -38,7 +42,7 @@ def build_system(self) -> BuildSystem:
3842
build_backend = None
3943
requires = None
4044

41-
if not self.file.exists():
45+
if not self.path.exists():
4246
build_backend = "poetry.core.masonry.api"
4347
requires = ["poetry-core"]
4448

@@ -68,7 +72,7 @@ def poetry_config(self) -> dict[str, Any]:
6872
def is_poetry_project(self) -> bool:
6973
from poetry.core.pyproject.exceptions import PyProjectException
7074

71-
if self.file.exists():
75+
if self.path.exists():
7276
with suppress(PyProjectException):
7377
_ = self.poetry_config
7478
return True

0 commit comments

Comments
 (0)