Repository: astral-sh/uv
File: crates/uv-requirements/src/sources.rs (Rust)

Code before:
use std::ffi::OsStr;
use std::path::{Path, PathBuf};

use anyhow::{Context, Result};
use console::Term;

use uv_fs::{CWD, Simplified};
use uv_requirements_txt::RequirementsTxtRequirement;

#[derive(Debug, Clone)]
pub enum RequirementsSource {
    /// A package was provided on the command line (e.g., `pip install flask`).
    Package(RequirementsTxtRequirement),
    /// An editable path was provided on the command line (e.g., `pip install -e ../flask`).
    Editable(RequirementsTxtRequirement),
    /// Dependencies were provided via a Pep723 script file.
    Pep723Script(PathBuf),
    /// Dependencies were provided via a `pylock.toml` file.
    PylockToml(PathBuf),
    /// Dependencies were provided via a `requirements.txt` file (e.g., `pip install -r requirements.txt`).
    RequirementsTxt(PathBuf),
    /// Dependencies were provided via a `pyproject.toml` file (e.g., `pip-compile pyproject.toml`).
    PyprojectToml(PathBuf),
    /// Dependencies were provided via a `setup.py` file (e.g., `pip-compile setup.py`).
    SetupPy(PathBuf),
    /// Dependencies were provided via a `setup.cfg` file (e.g., `pip-compile setup.cfg`).
    SetupCfg(PathBuf),
    /// Dependencies were provided via an unsupported Conda `environment.yml` file (e.g., `pip install -r environment.yml`).
    EnvironmentYml(PathBuf),
}

impl RequirementsSource {
    /// Parse a [`RequirementsSource`] from a [`PathBuf`]. The file type is determined by the file
    /// extension.
    pub fn from_requirements_file(path: PathBuf) -> Result<Self> {
        if path.ends_with("pyproject.toml") {
            Ok(Self::PyprojectToml(path))
        } else if path.ends_with("setup.py") {
            Ok(Self::SetupPy(path))
        } else if path.ends_with("setup.cfg") {
            Ok(Self::SetupCfg(path))

Review comment (suggestion):
We should stylize this consistently
```suggestion
    /// Dependencies were provided via a PEP 723 script.
```

Code after:
use std::ffi::OsStr;
use std::path::{Path, PathBuf};

use anyhow::{Context, Result};
use console::Term;

use uv_fs::{CWD, Simplified};
use uv_requirements_txt::RequirementsTxtRequirement;

#[derive(Debug, Clone)]
pub enum RequirementsSource {
    /// A package was provided on the command line (e.g., `pip install flask`).
    Package(RequirementsTxtRequirement),
    /// An editable path was provided on the command line (e.g., `pip install -e ../flask`).
    Editable(RequirementsTxtRequirement),
    /// Dependencies were provided via a PEP 723 script.
    Pep723Script(PathBuf),
    /// Dependencies were provided via a `pylock.toml` file.
    PylockToml(PathBuf),
    /// Dependencies were provided via a `requirements.txt` file (e.g., `pip install -r requirements.txt`).
    RequirementsTxt(PathBuf),
    /// Dependencies were provided via a `pyproject.toml` file (e.g., `pip-compile pyproject.toml`).
    PyprojectToml(PathBuf),
    /// Dependencies were provided via a `setup.py` file (e.g., `pip-compile setup.py`).
    SetupPy(PathBuf),
    /// Dependencies were provided via a `setup.cfg` file (e.g., `pip-compile setup.cfg`).
    SetupCfg(PathBuf),
    /// Dependencies were provided via an unsupported Conda `environment.yml` file (e.g., `pip install -r environment.yml`).
    EnvironmentYml(PathBuf),
}

impl RequirementsSource {
    /// Parse a [`RequirementsSource`] from a [`PathBuf`]. The file type is determined by the file
    /// extension.
    pub fn from_requirements_file(path: PathBuf) -> Result<Self> {
        if path.ends_with("pyproject.toml") {
            Ok(Self::PyprojectToml(path))
        } else if path.ends_with("setup.py") {
            Ok(Self::SetupPy(path))
        } else if path.ends_with("setup.cfg") {
            Ok(Self::SetupCfg(path))