Project Analyzer

Project analyzer - extracts metadata from existing Python projects.

class pypreset.project_analyzer.PackageManager[source]

Bases: StrEnum

Detected package manager.

POETRY = 'poetry'
PDM = 'pdm'
SETUPTOOLS = 'setuptools'
HATCH = 'hatch'
FLIT = 'flit'
UNKNOWN = 'unknown'
__new__(value)
class pypreset.project_analyzer.DetectedLinter[source]

Bases: StrEnum

Detected linting/formatting tools.

RUFF = 'ruff'
BLACK = 'black'
FLAKE8 = 'flake8'
ISORT = 'isort'
NONE = 'none'
__new__(value)
class pypreset.project_analyzer.DetectedTestFramework[source]

Bases: StrEnum

Detected testing framework.

PYTEST = 'pytest'
UNITTEST = 'unittest'
NONE = 'none'
__new__(value)
class pypreset.project_analyzer.DetectedTypeChecker[source]

Bases: StrEnum

Detected type checker.

MYPY = 'mypy'
PYRIGHT = 'pyright'
NONE = 'none'
__new__(value)
class pypreset.project_analyzer.AnalysisConfidence[source]

Bases: object

Confidence levels for detected values.

Parameters:
HIGH: Literal['high'] = 'high'
MEDIUM: Literal['medium'] = 'medium'
LOW: Literal['low'] = 'low'
__init__(HIGH='high', MEDIUM='medium', LOW='low')
Parameters:
Return type:

None

class pypreset.project_analyzer.DetectedValue[source]

Bases: Generic

A detected value with confidence level.

Parameters:
value: T
confidence: Literal['high', 'medium', 'low']
source: str
property is_reliable: bool

Check if value is reliable enough to use without confirmation.

__init__(value, confidence, source)
Parameters:
Return type:

None

class pypreset.project_analyzer.MissingField[source]

Bases: object

Represents a field that could not be detected.

Parameters:
name: str
description: str
required: bool
default: Any = None
choices: list[str] | None = None
__init__(name, description, required, default=None, choices=None)
Parameters:
Return type:

None

class pypreset.project_analyzer.ProjectAnalysis[source]

Bases: object

Complete analysis of an existing project.

Parameters:
project_name: DetectedValue[str] | None = None
package_name: DetectedValue[str] | None = None
version: DetectedValue[str] | None = None
description: DetectedValue[str] | None = None
python_version: DetectedValue[str] | None = None
package_manager: DetectedValue[PackageManager] | None = None
test_framework: DetectedValue[DetectedTestFramework] | None = None
has_tests_dir: bool = False
existing_tests: list[Path]
linter: DetectedValue[DetectedLinter] | None = None
type_checker: DetectedValue[DetectedTypeChecker] | None = None
line_length: DetectedValue[int] | None = None
has_github_dir: bool = False
existing_workflows: list[Path]
has_dependabot: bool = False
has_readme: bool = False
repository_url: DetectedValue[str] | None = None
license_id: DetectedValue[str] | None = None
has_gitignore: bool = False
has_src_layout: bool = False
source_dirs: list[str]
main_dependencies: list[str]
dev_dependencies: list[str]
missing_fields: list[MissingField]
get_reliable_values()[source]

Get all values that are reliable enough to use without confirmation.

Return type:

dict[str, Any]

get_uncertain_values()[source]

Get values that were detected but need confirmation.

Return type:

dict[str, DetectedValue[Any]]

__init__(project_name=None, package_name=None, version=None, description=None, python_version=None, package_manager=None, test_framework=None, has_tests_dir=False, existing_tests=<factory>, linter=None, type_checker=None, line_length=None, has_github_dir=False, existing_workflows=<factory>, has_dependabot=False, has_readme=False, repository_url=None, license_id=None, has_gitignore=False, has_src_layout=False, source_dirs=<factory>, main_dependencies=<factory>, dev_dependencies=<factory>, missing_fields=<factory>)
Parameters:
Return type:

None

class pypreset.project_analyzer.ProjectAnalyzer[source]

Bases: object

Analyzes an existing Python project to extract metadata and configuration.

Parameters:

project_dir (Path)

__init__(project_dir)[source]
Parameters:

project_dir (Path)

Return type:

None

pyproject_data: dict[str, Any]
analyze()[source]

Perform complete project analysis.

Return type:

ProjectAnalysis

pypreset.project_analyzer.analyze_project(project_dir)[source]

Convenience function to analyze a project.

Parameters:

project_dir (Path)

Return type:

ProjectAnalysis