astral-sh/uv · error · anyhow::Error
`{}` is not a valid PEP 751 filename: expected `pylock.toml`
Error message
`{}` is not a valid PEP 751 filename: expected `pylock.toml` or `pylock.<name>.toml`, where `<name>` is non-empty and contains no dots What it means
Error "`{}` is not a valid PEP 751 filename: expected `pylock.toml` or `pylock.<name>.toml`, where `<name>` is non-empty and contains no dots" thrown in astral-sh/uv.
Source
Thrown at crates/uv-requirements/src/sources.rs:61
} else if path.ends_with("setup.cfg") {
Ok(Self::SetupCfg(path))
} else if path.ends_with("environment.yml") {
Ok(Self::EnvironmentYml(path))
} else if path
.file_name()
.is_some_and(|file_name| file_name.to_str().is_some_and(is_pylock_toml))
{
Ok(Self::PylockToml(path))
} else if path
.extension()
.is_some_and(|ext| ext.eq_ignore_ascii_case("py") || ext.eq_ignore_ascii_case("pyw"))
{
Ok(Self::Pep723Script(path))
} else if path
.extension()
.is_some_and(|ext| ext.eq_ignore_ascii_case("toml"))
{
Err(anyhow::anyhow!(
"`{}` is not a valid PEP 751 filename: expected `pylock.toml` or `pylock.<name>.toml`, where `<name>` is non-empty and contains no dots",
path.user_display(),
))
} else if path
.extension()
.is_some_and(|ext| ext.eq_ignore_ascii_case("txt") || ext.eq_ignore_ascii_case("in"))
{
Ok(Self::RequirementsTxt(path))
} else if path.extension().is_none() {
// If we don't have an extension, mark it as extensionless so we can detect
// the format later (either a PEP 723 script or a requirements.txt file).
Ok(Self::Extensionless(path))
} else {
Ok(Self::RequirementsTxt(path))
}
}
/// Parse a [`RequirementsSource`] from a `requirements.txt` file.View on GitHub (pinned to f1a42680ff)
When it happens
Trigger: Thrown at crates/uv-requirements/src/sources.rs:61 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of astral-sh/uv@f1a42680ff (2026-08-16).
Data as JSON: /api/errors/6e9c610cd916fa69.
Report an issue: GitHub.