Source code for

import logging
from typing import TYPE_CHECKING, List

from prospector.finder import FileFinder
from prospector.message import Location, Message
from import ToolBase

    from prospector.config import ProspectorConfig

# HACK: pyroma configures logging in its so by importing,
# it will change existing logging configuration to DEBUG which causes
# problems with other 3rd party modules as everything now logs to
# stdout...
_old = logging.basicConfig
    logging.basicConfig = lambda **k: None
    from pyroma import projectdata, ratings

    # if pyroma doesn't exist, will raise an ImportError and be caught "upstream"
    # always restore logging.basicConfig
    logging.basicConfig = _old

    "Name": "PYR01",
    "Version": "PYR02",
    "VersionIsString": "PYR03",
    "PEPVersion": "PYR04",
    "Description": "PYR05",
    "LongDescription": "PYR06",
    "Classifiers": "PYR07",
    "PythonVersion": "PYR08",
    "Keywords": "PYR09",
    "Author": "PYR10",
    "AuthorEmail": "PYR11",
    "Url": "PYR12",
    "License": "PYR13",
    "LicenceClassifier": "PYR14",
    "ZipSafe": "PYR15",
    "SDist": "PYR16",
    "PackageDocs": "PYR17",
    "ValidREST": "PYR18",
    "BusFactor": "PYR19",


def _copy_codes():
    for name, code in PYROMA_ALL_CODES.items():
        if hasattr(ratings, name):
            PYROMA_CODES[getattr(ratings, name)] = code


PYROMA_TEST_CLASSES = [t.__class__ for t in ratings.ALL_TESTS]

[docs] class PyromaTool(ToolBase): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.ignore_codes = ()
[docs] def configure(self, prospector_config: "ProspectorConfig", found_files: FileFinder): self.ignore_codes = prospector_config.get_disabled_messages("pyroma")
[docs] def run(self, found_files: FileFinder) -> List[Message]: messages = [] for directory in found_files.directories: # just list directories which are not ignored, but find any `` ourselves # as that is excluded by default for filepath in directory.iterdir(): if filepath.is_dir() or != "": continue data = projectdata.get_data(directory.resolve()) all_tests = [m() for m in PYROMA_TEST_CLASSES] for test in all_tests: code = PYROMA_CODES.get(test.__class__, "PYRUNKNOWN") if code in self.ignore_codes: continue passed = test.test(data) if passed is False: # passed can be True, False or None... loc = Location(filepath, "setup", None, -1, -1) msg = Message("pyroma", code, loc, test.message()) messages.append(msg) return messages