CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-pyroma

Python packaging quality assessment tool that evaluates how well Python projects comply with best practices of the Python packaging ecosystem.

Pending
Overview
Eval results
Files

rating-system.mddocs/

Rating System

Comprehensive quality assessment system with pluggable tests that evaluate various aspects of Python packaging best practices. The rating system provides detailed feedback, actionable recommendations, and numerical scores from 0-10 with humorous cheese-themed descriptions.

Capabilities

Core Rating Function

rate(data, skip_tests=None)

def rate(data, skip_tests=None):
    """Rate package metadata quality using comprehensive test suite.
    
    Args:
        data: Package metadata dictionary from data extraction modules
        skip_tests: List of test class names to skip during evaluation
        
    Returns:
        tuple: (rating: int, failures: list[str])
               - rating: Numerical score from 0-10
               - failures: List of failure messages for failed tests
               
    Example:
        >>> data = projectdata.get_data('/path/to/project')
        >>> rating, failures = rate(data)
        >>> print(f"Rating: {rating}/10")
        >>> for failure in failures:
        ...     print(f"- {failure}")
    """

The main rating function that:

  • Runs all enabled tests against package metadata
  • Calculates weighted score based on test importance
  • Returns detailed failure messages for improvement guidance
  • Supports fatal tests that force rating to 0
  • Handles test skipping for specific use cases

Test Discovery

get_all_tests()

def get_all_tests():
    """Get list of all available test class names.
    
    Returns:
        list: List of test class names for use with skip_tests parameter
        
    Example:
        ['Name', 'Version', 'VersionIsString', 'PEPVersion', 'Description',
         'LongDescription', 'Classifiers', 'ClassifierVerification', ...]
    """

get_code_licenses()

def get_code_licenses():
    """Build mapping of license short codes to classifier strings.
    
    Returns:
        dict: Mapping from license codes (e.g., 'MIT', 'GPL') to 
              sets of corresponding trove classifiers
              
    Example:
        {'MIT': {'License :: OSI Approved :: MIT License'},
         'GPL': {'License :: OSI Approved :: GNU General Public License v2 (GPLv2)', ...}}
    """

Constants and Configuration

ALL_TESTS

ALL_TESTS: list
"""List of all available test instances.

Contains instantiated test objects for all quality checks.
Used internally by the rating system to run evaluations.
"""

LEVELS

LEVELS: list
"""Rating descriptions with cheese-themed messages.

Index corresponds to rating (0-10):
- 0: "This cheese seems to contain no dairy products"  
- 1: "Vieux Bologne"
- 2: "Limburger"
- ...
- 10: "Your cheese is so fresh most people think it's a cream: Mascarpone"
"""

CODE_LICENSES

CODE_LICENSES: dict
"""Mapping of license codes to trove classifier sets.

Built from trove-classifiers package, provides lookup from
common license abbreviations to their full classifier names.
"""

PEP386_RE

PEP386_RE: re.Pattern
"""Compiled regex pattern for validating PEP-386 version format.

Used internally by PEPVersion test to validate legacy version formats.
Matches versions like '1.0', '1.0.1', '1.0a1', '1.0.post1', '1.0.dev1'.
"""

PEP440_RE

PEP440_RE: re.Pattern
"""Compiled regex pattern for validating PEP-440 version format.

Used internally by PEPVersion test to validate modern version formats.
Supports epochs, pre-releases, post-releases, dev releases, and local versions.
"""

SHORT_NAME_RE

SHORT_NAME_RE: re.Pattern
"""Compiled regex pattern for extracting license short names from classifiers.

Used by get_code_licenses() to parse license abbreviations from
trove classifier strings like 'License :: OSI Approved :: MIT License'.
"""

Test Classes

The rating system includes comprehensive tests organized by category:

Fatal Tests

Tests that must pass for any meaningful rating:

Name

  • Verifies package has a name field
  • Fatal: Package receives rating 0 if missing

Version

  • Verifies package has a version field
  • Fatal: Package receives rating 0 if missing

Version Validation

VersionIsString

  • Ensures version is a string type (weight: 50)

PEPVersion

  • Validates version format against PEP-440 standard (weight: 50)
  • Gives reduced weight for PEP-386 compliance only (weight: 10)

Description and Documentation

Description

  • Checks for package description > 10 characters (weight: 100)
  • Fatal if no description exists

LongDescription

  • Verifies long description > 100 characters (weight: 50)

ValidREST

  • Validates ReStructuredText syntax in long description (weight: 50)
  • Skips validation for markdown/plain text content types

Metadata Completeness

Classifiers

  • Requires presence of trove classifiers (weight: 100)

ClassifierVerification

  • Validates classifiers against official trove classifier list (weight: 20)
  • Allows private classifiers with "Private :: " prefix

PythonClassifierVersion

  • Checks for specific Python version classifiers (weight: 25-100)
  • Higher weight for detailed version specifications

PythonRequiresVersion

  • Validates python_requires field with PEP-508 syntax (weight: 100)

Keywords

  • Checks for keywords field (weight: 20)

Contact Information

Author

  • Requires author field or author name in author_email (weight: 100)

AuthorEmail

  • Requires author_email field (weight: 100)

Url

  • Requires project URL or project_urls field (weight: 20)

Licensing

Licensing

  • Validates license information consistency (weight: 50)
  • Checks license field, license_expression, and license classifiers
  • Prevents ambiguous license specifications

DevStatusClassifier

  • Encourages development status classifier (weight: 20)

Distribution and Maintenance

SDist

  • Checks for source distribution on PyPI (weight: 100)
  • Only applies to PyPI analysis mode

BusFactor

  • Evaluates number of package owners on PyPI (weight: 50-100)
  • Encourages multiple maintainers for reliability

Build System Validation

MissingBuildSystem

  • Warns about setup.cfg without build system definition (weight: 200)

MissingPyProjectToml

  • Encourages pyproject.toml adoption (weight: 100)

StoneAgeSetupPy

  • Warns about outdated setup.py usage (weight: 200)

Optional Tests

CheckManifest

  • Integrates check-manifest tool if available (weight: dynamic)
  • Validates MANIFEST.in completeness and packaging consistency
  • Weight starts at 0, becomes 200 when applicable to project
  • Only runs if check-manifest package is installed and project has a path
  • Detects missing files in source distributions
  • Helps ensure all necessary files are included in published packages

Usage Examples

from pyroma.ratings import rate, get_all_tests, LEVELS
from pyroma.projectdata import get_data

# Basic rating
data = get_data('/path/to/project')
rating, failures = rate(data)
print(f"Rating: {rating}/10 - {LEVELS[rating]}")

# Skip specific tests
rating, failures = rate(data, skip_tests=['BusFactor', 'SDist'])

# List available tests
tests = get_all_tests()
print("Available tests:", ', '.join(tests))

# Detailed analysis
if failures:
    print("Issues found:")
    for failure in failures:
        print(f"  - {failure}")
else:
    print("No issues found!")

Test Base Classes

BaseTest

class BaseTest:
    """Base class for all quality assessment tests.
    
    Attributes:
        fatal: bool - If True, failure results in rating 0
        weight: int - Relative importance for scoring (default varies)
    """
    
    fatal: bool = False
    weight: int
    
    def test(self, data): ...
    def message(self): ...

FieldTest

class FieldTest(BaseTest):
    """Base class for tests checking field presence and non-emptiness.
    
    Attributes:
        field: str - Metadata field name to check
    """
    
    field: str
    
    def test(self, data): ...
    def message(self): ...

Install with Tessl CLI

npx tessl i tessl/pypi-pyroma

docs

core-analysis.md

data-extraction.md

index.md

rating-system.md

tile.json