34 lines
928 B
Python
34 lines
928 B
Python
from pathlib import Path
|
|
from typing import Optional
|
|
|
|
from ..entry import Entry
|
|
|
|
|
|
class PythonEntry(Entry):
|
|
TYPE: str = "python"
|
|
COMMANDS = {
|
|
"setup": [
|
|
["poetry", "env", "use", "3.8"],
|
|
["poetry", "install"],
|
|
],
|
|
"lint": [
|
|
["poetry", "run", "black", "--check", "--diff", "./"],
|
|
["poetry", "run", "isort", "--profile", "black", "--check-only", "./"],
|
|
],
|
|
"format": [
|
|
["poetry", "run", "isort", "./"],
|
|
["poetry", "run", "black", "./"],
|
|
],
|
|
"test": [
|
|
["poetry", "run", "pytest", "-p", "no:warnings"],
|
|
],
|
|
}
|
|
|
|
def __init__(self, basepath: Path):
|
|
super().__init__(self.TYPE, self.COMMANDS, basepath)
|
|
|
|
@classmethod
|
|
def detect(cls, basepath: Path) -> Optional["PythonEntry"]:
|
|
if (basepath / "pyproject.toml").exists():
|
|
return cls(basepath)
|