Antilint
This commit is contained in:
parent
c08b01300a
commit
00784ffa56
@ -15,6 +15,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Scone. If not, see <https://www.gnu.org/licenses/>.
|
||||
from pathlib import Path
|
||||
from typing import List, Optional
|
||||
|
||||
from scone.common.modeutils import DEFAULT_MODE_FILE
|
||||
from scone.default.steps.filesystem_steps import (
|
||||
@ -156,7 +157,7 @@ class SystemdTimer(Recipe):
|
||||
)
|
||||
|
||||
if isinstance(self.calendar, str):
|
||||
calendars = [self.calendar]
|
||||
calendars: Optional[List[str]] = [self.calendar]
|
||||
elif isinstance(self.calendar, list):
|
||||
calendars = self.calendar
|
||||
else:
|
||||
|
@ -31,10 +31,12 @@ async def depend_remote_file(path: str, kitchen: Kitchen) -> None:
|
||||
|
||||
|
||||
def template_jinja2_builtin(path: Path, **template_vars: Any) -> str:
|
||||
template = path.read_text("UTF-8")
|
||||
template_text = path.read_text("UTF-8")
|
||||
|
||||
try:
|
||||
env = Environment(loader=DictLoader({str(path): template}), autoescape=False)
|
||||
env = Environment(
|
||||
loader=DictLoader({str(path): template_text}), autoescape=False
|
||||
)
|
||||
template = env.get_template(str(path))
|
||||
return template.render(template_vars)
|
||||
except Exception as e:
|
||||
|
@ -239,10 +239,17 @@ class DependencyVarProxy:
|
||||
return raw_value
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self.raw_())
|
||||
raw = self.raw_()
|
||||
if not isinstance(raw, dict) and not isinstance(raw, list):
|
||||
raise TypeError("Trying to iterate over non-iterable")
|
||||
return iter(raw)
|
||||
|
||||
def __contains__(self, item):
|
||||
return item in self.raw_()
|
||||
raw = self.raw_()
|
||||
if isinstance(raw, list) or isinstance(raw, str) or isinstance(raw, dict):
|
||||
return item in raw
|
||||
else:
|
||||
raise TypeError("Not a container")
|
||||
|
||||
|
||||
class DependencyCache:
|
||||
|
@ -257,6 +257,7 @@ def convert_textx_recipe(txrecipe_or_subblock, parent: Optional[MenuBlock]):
|
||||
other_value = convert_textx_value(directive.other_value)
|
||||
assert isinstance(var, str)
|
||||
assert isinstance(op, str)
|
||||
assert isinstance(other_value, str)
|
||||
recipe.control_directives.append(IfCondDirective(var, op, other_value))
|
||||
else:
|
||||
raise ValueError(f"Unknown directive {directive}")
|
||||
@ -312,6 +313,7 @@ def convert_textx_block(txblock, parent: Optional[MenuBlock]) -> MenuBlock:
|
||||
other_value = convert_textx_value(directive.other_value)
|
||||
assert isinstance(var, str)
|
||||
assert isinstance(op, str)
|
||||
assert isinstance(other_value, str)
|
||||
block.control_directives.append(IfCondDirective(var, op, other_value))
|
||||
elif isinstance(directive, scoml_classes["ImportDirective"]):
|
||||
block.import_directives.append(directive.importee)
|
||||
|
31
setup.py
31
setup.py
@ -39,25 +39,34 @@ EX_SOUS_DOCKER = ["docker"]
|
||||
|
||||
EX_SOUS_ALL = EX_SOUS_BASE + EX_SOUS_PG + EX_SOUS_MYSQL + EX_SOUS_DOCKER
|
||||
|
||||
EX_DEV_MYPY = [
|
||||
"types-toml",
|
||||
"types-requests"
|
||||
]
|
||||
EX_HEAD = [
|
||||
"SecretStorage~=3.1.2",
|
||||
"asyncssh[libnacl]~=2.2.1",
|
||||
"toposort~=1.5",
|
||||
"pynacl",
|
||||
"aiosqlite~=0.15.0",
|
||||
"requests",
|
||||
"Jinja2",
|
||||
"typeguard",
|
||||
"textx",
|
||||
]
|
||||
|
||||
EX_DEV = EX_SOUS_ALL + EX_HEAD + EX_DEV_MYPY
|
||||
|
||||
# What packages are optional?
|
||||
EXTRAS = {
|
||||
"head": [
|
||||
"SecretStorage~=3.1.2",
|
||||
"asyncssh[libnacl]~=2.2.1",
|
||||
"toposort~=1.5",
|
||||
"pynacl",
|
||||
"aiosqlite~=0.15.0",
|
||||
"requests",
|
||||
"Jinja2",
|
||||
"typeguard",
|
||||
"textx",
|
||||
],
|
||||
"head": EX_HEAD,
|
||||
"sous": EX_SOUS_ALL,
|
||||
"sous-core": EX_SOUS_BASE,
|
||||
"sous-pg": EX_SOUS_PG,
|
||||
"sous-mysql": EX_SOUS_MYSQL,
|
||||
"sous-docker": EX_SOUS_DOCKER,
|
||||
"mypy": EX_DEV_MYPY,
|
||||
"dev": EX_DEV
|
||||
}
|
||||
|
||||
# The rest you shouldn't have to touch too much :)
|
||||
|
Loading…
x
Reference in New Issue
Block a user