Find the absolute filepath to a pyproject.toml if it exists
(
path_search_start: tuple[str, ...], stdin_filename: str | None = None
)
| 96 | |
| 97 | |
| 98 | def find_pyproject_toml( |
| 99 | path_search_start: tuple[str, ...], stdin_filename: str | None = None |
| 100 | ) -> str | None: |
| 101 | """Find the absolute filepath to a pyproject.toml if it exists""" |
| 102 | path_project_root, _ = find_project_root(path_search_start, stdin_filename) |
| 103 | path_pyproject_toml = path_project_root / "pyproject.toml" |
| 104 | if path_pyproject_toml.is_file(): |
| 105 | return str(path_pyproject_toml) |
| 106 | |
| 107 | try: |
| 108 | path_user_pyproject_toml = find_user_pyproject_toml() |
| 109 | return ( |
| 110 | str(path_user_pyproject_toml) |
| 111 | if path_user_pyproject_toml.is_file() |
| 112 | else None |
| 113 | ) |
| 114 | except (PermissionError, RuntimeError) as e: |
| 115 | # We do not have access to the user-level config directory, so ignore it. |
| 116 | err(f"Ignoring user configuration directory due to {e!r}") |
| 117 | return None |
| 118 | |
| 119 | |
| 120 | @mypyc_attr(patchable=True) |
no test coverage detected