Toward #1311, we want a standalone is_likely_used function which would take a ToolSpec and ConfigSpec and basically just give the current implementation for Tool.is_used, i.e. the default implementation.
Tool.is_used would be refactored to use is_likely_used using self for the ToolSpec and self.config_spec for the ConfigSpec.
Tool.is_used, whose current implementation would serve as the basis for is_likely_used, currently uses Tool.is_declared_as_dep, which should be moved into ToolSpec so it is accessible from the ToolSpec arg. It also uses Tool.is_config_present which uses a Tool._is_config_spec_present helper method together with ConfigSpec from Tool.config_spec. We should move the Tool._is_config_spec_present method to ConfigSpec.is_present since it doesn't actually use the self arg in Tool at all. Then, is_likely_used can just use ConfigSpec.is_present directly from the ConfigSpec passed as an argument.
Lastly, Tool.is_used uses Tool.is_pre_commit_config_present. This, along with its dependent method Tool.get_pre_commit_repos should be moved into ToolSpec.
The ToolSpec implementation should be moved into a new module called usethis._tool.spec.
The new standalone is_likely_used method should be put into a new usethis._tool.heuristics module.
The new module layering for usethis._tool should be like the following:
layers =
all_
impl
base
heuristics
spec
config | pre_commit | rule
Toward #1311, we want a standalone
is_likely_usedfunction which would take aToolSpecandConfigSpecand basically just give the current implementation forTool.is_used, i.e. the default implementation.Tool.is_usedwould be refactored to useis_likely_usedusingselffor theToolSpecandself.config_specfor theConfigSpec.Tool.is_used, whose current implementation would serve as the basis foris_likely_used, currently usesTool.is_declared_as_dep, which should be moved intoToolSpecso it is accessible from theToolSpecarg. It also usesTool.is_config_presentwhich uses aTool._is_config_spec_presenthelper method together withConfigSpecfromTool.config_spec. We should move theTool._is_config_spec_presentmethod toConfigSpec.is_presentsince it doesn't actually use theselfarg inToolat all. Then,is_likely_usedcan just useConfigSpec.is_presentdirectly from theConfigSpecpassed as an argument.Lastly,
Tool.is_usedusesTool.is_pre_commit_config_present. This, along with its dependent methodTool.get_pre_commit_reposshould be moved intoToolSpec.The
ToolSpecimplementation should be moved into a new module calledusethis._tool.spec.The new standalone
is_likely_usedmethod should be put into a newusethis._tool.heuristicsmodule.The new module layering for
usethis._toolshould be like the following:layers =
all_
impl
base
heuristics
spec
config | pre_commit | rule