src/nitpick/project.py
def read_configuration(self) -> Configuration:
        """Search for a configuration file and validate it against a Marshmallow schema."""
        config_file: Optional[Path] = None
        for possible_file in CONFIG_FILES:
            path: Path = self.root / possible_file
            if not path.exists():
                continue

            if not config_file:
                logger.info(f"Config file: reading from {path}")
                config_file = path
            else:
                logger.warning(f"Config file: ignoring existing {path}")

        if not config_file:
            logger.warning("Config file: none found")
            return Configuration(None, [], "")

        toml_format = TOMLFormat(path=config_file)
        config_dict = search_dict(TOOL_NITPICK_JMEX, toml_format.as_data, {})
        validation_errors = ToolNitpickSectionSchema().validate(config_dict)
        if not validation_errors:
            return Configuration(config_file, config_dict.get("style", []), config_dict.get("cache", ""))

        # pylint: disable=import-outside-toplevel
        from nitpick.plugins.info import FileInfo

        raise QuitComplainingError(
            Reporter(FileInfo(self, PYPROJECT_TOML)).make_fuss(
                StyleViolations.INVALID_DATA_TOOL_NITPICK,
                flatten_marshmallow_errors(validation_errors),
                section=TOOL_NITPICK,
            )
        )
Search for a configuration file and validate it against a Marshmallow schema.
Search for a configuration file and validate it against a Marshmallow schema.
Search for a configuration file and validate it against a Marshmallow schema .
def read_configuration(self) -> Configuration:
        config_file: Optional[Path] = None
        for possible_file in CONFIG_FILES:
            path: Path = self.root / possible_file
            if not path.exists():
                continue
            if not config_file:
                logger.info(f"Config file: reading from {path}")
                config_file = path
            else:
                logger.warning(f"Config file: ignoring existing {path}")
        if not config_file:
            logger.warning("Config file: none found")
            return Configuration(None, [], "")
        toml_format = TOMLFormat(path=config_file)
        config_dict = search_dict(TOOL_NITPICK_JMEX, toml_format.as_data, {})
        validation_errors = ToolNitpickSectionSchema().validate(config_dict)
        if not validation_errors:
            return Configuration(config_file, config_dict.get("style", []), config_dict.get("cache", ""))
        from nitpick.plugins.info import FileInfo
        raise QuitComplainingError(
            Reporter(FileInfo(self, PYPROJECT_TOML)).make_fuss(
                StyleViolations.INVALID_DATA_TOOL_NITPICK,
                flatten_marshmallow_errors(validation_errors),
                section=TOOL_NITPICK,
            )
        )
def read_configuration ( self ) -> Configuration : config_file : Optional [ Path ] = None for possible_file in CONFIG_FILES : path : Path = self . root / possible_file if not path . exists ( ) : continue if not config_file : logger . info ( f"Config file: reading from {path}" ) config_file = path else : logger . warning ( f"Config file: ignoring existing {path}" ) if not config_file : logger . warning ( "Config file: none found" ) return Configuration ( None , [ ] , "" ) toml_format = TOMLFormat ( path = config_file ) config_dict = search_dict ( TOOL_NITPICK_JMEX , toml_format . as_data , { } ) validation_errors = ToolNitpickSectionSchema ( ) . validate ( config_dict ) if not validation_errors : return Configuration ( config_file , config_dict . get ( "style" , [ ] ) , config_dict . get ( "cache" , "" ) ) from nitpick . plugins . info import FileInfo raise QuitComplainingError ( Reporter ( FileInfo ( self , PYPROJECT_TOML ) ) . make_fuss ( StyleViolations . INVALID_DATA_TOOL_NITPICK , flatten_marshmallow_errors ( validation_errors ) , section = TOOL_NITPICK , ) )
Search for a configuration file and validate it against a Marshmallow schema.
Search for a configuration file and validate it against a Marshmallow schema .
"""Search for a configuration file and validate it against a Marshmallow schema.""" # pylint: disable=import-outside-toplevel
self