Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

install ruff in dev environment #1514

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions copier/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,18 @@ class CopierApp(cli.Application):
"""The Copier CLI application."""

DESCRIPTION = "Create a new project from a template."
DESCRIPTION_MORE = (
dedent(
"""\
DESCRIPTION_MORE = dedent(
"""\
Docs in https://copier.readthedocs.io/

"""
)
+ (
colors.yellow
| dedent(
"""\
) + (
colors.yellow
| dedent(
"""\
WARNING! Use only trusted project templates, as they might
execute code with the same level of access as your user.\n
"""
)
)
)
VERSION = copier_version()
Expand Down
40 changes: 27 additions & 13 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pytest-cov = ">=3.0.0"
pytest-gitconfig = ">=0.6.0"
pytest-xdist = ">=2.5.0"
types-backports = ">=0.1.3"
ruff = "==0.2.1"
types-decorator = ">=5.1.1"
types-pyyaml = ">=6.0.4"
types-psutil = "*"
Expand Down
6 changes: 2 additions & 4 deletions tests/test_answersfile_templating.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ def template_path(tmp_path_factory: pytest.TempPathFactory) -> str:
root = tmp_path_factory.mktemp("template")
build_file_tree(
{
root
/ "{{ _copier_conf.answers_file }}.jinja": """\
root / "{{ _copier_conf.answers_file }}.jinja": """\
# Changes here will be overwritten by Copier
{{ _copier_answers|to_nice_yaml }}
""",
root
/ "copier.yml": """\
root / "copier.yml": """\
_answers_file: ".copier-answers-{{ module_name }}.yml"

module_name:
Expand Down
4 changes: 1 addition & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ def _template_path_with_dot_config(config_folder: str) -> str:
root = tmp_path_factory.mktemp("template")
build_file_tree(
{
root
/ config_folder
/ "{{ _copier_conf.answers_file }}.jinja": """\
root / config_folder / "{{ _copier_conf.answers_file }}.jinja": """\
# Changes here will be overwritten by Copier
{{ _copier_answers|to_nice_yaml }}
""",
Expand Down
4 changes: 2 additions & 2 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def test_invalid_config_data(
) -> None:
template = Template(conf_path)
with pytest.raises(InvalidConfigFileError):
template.config_data # noqa: B018
template.config_data # noqa: B018
if check_err:
_, err = capsys.readouterr()
assert check_err(err)
Expand Down Expand Up @@ -198,7 +198,7 @@ def test_config_data_empty() -> None:
def test_multiple_config_file_error() -> None:
template = Template("tests/demo_multi_config")
with pytest.raises(MultipleConfigFilesError):
template.config_data # noqa: B018
template.config_data # noqa: B018


# ConfigData
Expand Down
6 changes: 2 additions & 4 deletions tests/test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ def test_question_with_invalid_type(tmp_path_factory: pytest.TempPathFactory) ->
src, dst = map(tmp_path_factory.mktemp, ["src", "dst"])
build_file_tree(
{
src
/ "copier.yaml": """
src / "copier.yaml": """
bad:
type: invalid
default: 1
Expand All @@ -79,8 +78,7 @@ def test_answer_with_invalid_type(tmp_path_factory: pytest.TempPathFactory) -> N
src, dst = map(tmp_path_factory.mktemp, ["src", "dst"])
build_file_tree(
{
src
/ "copier.yaml": """
src / "copier.yaml": """
bad:
type: int
default: null
Expand Down
51 changes: 17 additions & 34 deletions tests/test_symlinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ def test_copy_symlink(tmp_path_factory: pytest.TempPathFactory) -> None:
repo.mkdir()
build_file_tree(
{
repo
/ "copier.yaml": """\
repo / "copier.yaml": """\
_preserve_symlinks: true
""",
repo / "target.txt": "Symlink target",
Expand Down Expand Up @@ -54,8 +53,7 @@ def test_copy_symlink_templated_name(tmp_path_factory: pytest.TempPathFactory) -
repo.mkdir()
build_file_tree(
{
repo
/ "copier.yaml": """\
repo / "copier.yaml": """\
_preserve_symlinks: true
symlink_name: symlink
""",
Expand Down Expand Up @@ -92,8 +90,7 @@ def test_copy_symlink_templated_target(
repo.mkdir()
build_file_tree(
{
repo
/ "copier.yaml": """\
repo / "copier.yaml": """\
_preserve_symlinks: true
target_name: target
""",
Expand Down Expand Up @@ -134,8 +131,7 @@ def test_copy_symlink_missing_target(tmp_path_factory: pytest.TempPathFactory) -
repo.mkdir()
build_file_tree(
{
repo
/ "copier.yaml": """\
repo / "copier.yaml": """\
_preserve_symlinks: true
""",
repo / "symlink.txt": Path("target.txt"),
Expand Down Expand Up @@ -171,8 +167,7 @@ def test_option_preserve_symlinks_false(
repo.mkdir()
build_file_tree(
{
repo
/ "copier.yaml": """\
repo / "copier.yaml": """\
_preserve_symlinks: false
""",
repo / "target.txt": "Symlink target",
Expand Down Expand Up @@ -207,8 +202,7 @@ def test_option_preserve_symlinks_default(
repo.mkdir()
build_file_tree(
{
repo
/ "copier.yaml": """\
repo / "copier.yaml": """\
""",
repo / "target.txt": "Symlink target",
repo / "symlink.txt": Path("target.txt"),
Expand Down Expand Up @@ -238,21 +232,17 @@ def test_update_symlink(tmp_path_factory: pytest.TempPathFactory) -> None:

build_file_tree(
{
src
/ ".copier-answers.yml.jinja": """\
src / ".copier-answers.yml.jinja": """\
# Changes here will be overwritten by Copier
{{ _copier_answers|to_nice_yaml }}
""",
src
/ "copier.yml": """\
src / "copier.yml": """\
_preserve_symlinks: true
""",
src
/ "aaaa.txt": """
src / "aaaa.txt": """
Lorem ipsum
""",
src
/ "bbbb.txt": """
src / "bbbb.txt": """
dolor sit amet
""",
src / "symlink.txt": Path("./aaaa.txt"),
Expand Down Expand Up @@ -298,21 +288,17 @@ def test_update_file_to_symlink(tmp_path_factory: pytest.TempPathFactory) -> Non

build_file_tree(
{
src
/ ".copier-answers.yml.jinja": """\
src / ".copier-answers.yml.jinja": """\
# Changes here will be overwritten by Copier
{{ _copier_answers|to_nice_yaml }}
""",
src
/ "copier.yml": """\
src / "copier.yml": """\
_preserve_symlinks: true
""",
src
/ "aaaa.txt": """
src / "aaaa.txt": """
Lorem ipsum
""",
src
/ "bbbb.txt": """
src / "bbbb.txt": """
dolor sit amet
""",
src / "cccc.txt": Path("./aaaa.txt"),
Expand Down Expand Up @@ -361,8 +347,7 @@ def test_exclude_symlink(tmp_path_factory: pytest.TempPathFactory) -> None:
repo.mkdir()
build_file_tree(
{
repo
/ "copier.yaml": """\
repo / "copier.yaml": """\
_preserve_symlinks: true
""",
repo / "target.txt": "Symlink target",
Expand Down Expand Up @@ -394,8 +379,7 @@ def test_pretend_symlink(tmp_path_factory: pytest.TempPathFactory) -> None:
repo.mkdir()
build_file_tree(
{
repo
/ "copier.yaml": """\
repo / "copier.yaml": """\
_preserve_symlinks: true
""",
repo / "target.txt": "Symlink target",
Expand Down Expand Up @@ -427,8 +411,7 @@ def test_copy_symlink_none_path(tmp_path_factory: pytest.TempPathFactory) -> Non
repo.mkdir()
build_file_tree(
{
repo
/ "copier.yaml": """\
repo / "copier.yaml": """\
_preserve_symlinks: true
render: false
""",
Expand Down
Loading