Skip to content

Commit

Permalink
Update global config to include tools
Browse files Browse the repository at this point in the history
Signed-off-by: guillemdb <guillem@fragile.tech>
  • Loading branch information
Guillemdb committed Sep 11, 2022
1 parent 1d3367a commit 425f7a6
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
6 changes: 4 additions & 2 deletions src/mloq/assets/mloq/mloq.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
globals:
project_name: ???
default_branch: main
owner: ???
author: ???
email: ???
description: ???
open_source: ???
project_url: ???
default_branch: main
use_poetry: False
license: "proprietary"

license:
Expand Down Expand Up @@ -51,7 +52,8 @@ package:
owner: ${globals.owner}
author: ${globals.author}
email: ${globals.email}
license: ${license.license}
license: ${globals.license}
use_poetry: ${globals.use_poetry}
python_versions:
- '3.7'
- '3.8'
Expand Down
15 changes: 9 additions & 6 deletions src/mloq/assets/shared/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% if package %}
{% if package and package.use_poetry %}
[tool.poetry]
name = "{{ package.project_name }}"
version = "0.0.0"
Expand Down Expand Up @@ -42,7 +42,7 @@ psutil= "^5.8"
pytest-xdist = "^2.5"
pre-commit = "^2.6"
pytest-rerunfailures= "^10.2"

{% if lint and "pyproject.toml" not in lint.ignore_files and lint.add_requirements%}
[tool.poetry.group.lint.dependencies]
colorama = "^0.4"
flake8 = "^3.9"
Expand All @@ -58,12 +58,15 @@ pycodestyle = "^2.7"
flakehell = "^0.9"
black = "^22.8"
pre-commit = "^2.15"

{% endif %}
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"{% endif %}

# black is the tool to format the source code
build-backend = "poetry.core.masonry.api"
{% elif package %}[build-system]
requires = ["setuptools >= 50.3.2", "wheel >= 0.29.0"]
build-backend = "setuptools.build_meta"
{% endif %}
{% if lint and "pyproject.toml" not in lint.ignore_files %}# black is the tool to format the source code
[tool.black]
line-length = 99
target-version = ['py37', 'py38', 'py39']
Expand Down
1 change: 1 addition & 0 deletions src/mloq/commands/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class GlobalsCMD(Command):
project_url = param.String("???", doc="GitHub project url")
default_branch = param.String(doc="Default branch of the project")
license = param.String("MIT", doc="Project license type")
use_poetry = param.Boolean(True, doc="Use poetry to manage dependencies?")

def interactive_config(self) -> DictConfig:
"""Generate the configuration of the project interactively."""
Expand Down
11 changes: 9 additions & 2 deletions src/mloq/commands/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,14 @@ class LintCMD(Command):
disable = param.Boolean(default=None, doc="Disable lint command?")
docstring_checks = param.Boolean(True, doc="Apply docstring checks?")
pyproject_extra = param.String("", doc="Additional pyproject.toml configuration")
project_name = param.String(doc="Select project name")
project_name = param.String("${globals.project_name}", doc="Select project name")
makefile = param.Boolean(True, doc="Add check and style commands to makefile")
poetry_requirements = param.Boolean(True, doc="Add check and style commands to makefile")
ignore_files = param.ListSelector(
default=[],
doc="Ignore the following files",
objects=[f.dst for f in LINT_FILES],
)

def interactive_config(self) -> DictConfig:
"""Generate the configuration of the project interactively."""
Expand All @@ -37,4 +43,5 @@ def interactive_config(self) -> DictConfig:
def record_files(self) -> None:
"""Register the files that will be generated by mloq."""
for _file in self.files:
self.record.register_file(file=_file, path=Path())
if _file.dst not in self.record.config.lint.ignore_files:
self.record.register_file(file=_file, path=Path())
2 changes: 1 addition & 1 deletion src/mloq/commands/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class PackageCMD(Command):
doc="Supported python versions",
objects=PYTHON_VERSIONS,
)
pipenv = param.Boolean(False, doc="Add pipenv support to the project configuration")
use_poetry = param.Boolean("${globals.use_poetry}", doc="Add pipenv support to the project configuration")

def parse_config(self) -> DictConfig:
"""Update the configuration DictConfig with the Command parameters."""
Expand Down

0 comments on commit 425f7a6

Please sign in to comment.