Repository: pdm-project/pdm
Pull request #1673 (2023-02-04 20:58:31)

feat: accept --ignore-remembered in pdm init
Closes: #1672


eltoder: A simpler alternative is to always pass `ignore_remembered=False` in init, if this is acceptable.
frostming: Thanks, can you modify to always ignore remembered?
eltoder: @frostming done, please take a look
frostming: Please also fix the test case `tests/cli/test_init.py::test_init_non_interactive`
eltoder: Sorry, missed that. Fixed now.
codecov-commenter: # [Codecov](https://codecov.io/gh/pdm-project/pdm/pull/1673?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pdm-project) Report
Base: **85.16**% // Head: **85.16**% // No change to project coverage :thumbsup:
> Coverage data is based on head [(`f82a1cb`)](https://codecov.io/gh/pdm-project/pdm/pull/1673?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pdm-project) compared to base [(`78f14b7`)](https://codecov.io/gh/pdm-project/pdm/commit/78f14b7e3656bb67b6928f23af71183523155816?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pdm-project).
> Patch has no changes to coverable lines.

:mega: This organization is not using Codecov’s [GitHub App Integration](https://github.com/apps/codecov). We recommend you install it so Codecov can continue to function properly for your repositories. [Learn more](https://about.codecov.io/blog/codecov-is-updating-its-github-integration/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pdm-project)

<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##             main    #1673   +/-   ##
=======================================
  Coverage   85.16%   85.16%           
=======================================
  Files          92       92           
  Lines        8588     8588           
  Branches     1854     1854           
=======================================
  Hits         7314     7314           
  Misses        857      857           
  Partials      417      417           
```

| Flag | Coverage Δ | |
|---|---|---|
| unittests | `84.97% <ø> (ø)` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pdm-project#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/pdm-project/pdm/pull/1673?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pdm-project) | Coverage Δ | |
|---|---|---|
| [src/pdm/cli/commands/init.py](https://codecov.io/gh/pdm-project/pdm/pull/1673?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pdm-project#diff-c3JjL3BkbS9jbGkvY29tbWFuZHMvaW5pdC5weQ==) | `94.28% <ø> (ø)` | |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pdm-project). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pdm-project)

</details>

[:umbrella: View full report at Codecov](https://codecov.io/gh/pdm-project/pdm/pull/1673?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pdm-project).   
:loudspeaker: Do you have feedback about the report comment? [Let us know in this issue](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pdm-project).


Patch:
diff --git a/news/1672.feature.md b/news/1672.feature.md
new file mode 100644
index 00000000..8be8fe62
--- /dev/null
+++ b/news/1672.feature.md
@@ -0,0 +1,1 @@
+Always ignore remembered selection in pdm init.
diff --git a/src/pdm/cli/commands/init.py b/src/pdm/cli/commands/init.py
index e2a85c9a..22c86a53 100644
--- a/src/pdm/cli/commands/init.py
+++ b/src/pdm/cli/commands/init.py
@@ -61,6 +61,7 @@ class Command(BaseCommand):
                 project,
                 options.python or "",
                 first=bool(options.python),
+                ignore_remembered=True,
                 ignore_requires_python=True,
                 hooks=hooks,
             )
@@ -89,7 +90,8 @@ class Command(BaseCommand):
             python = actions.do_use(
                 project,
                 options.python or "3",
-                True,
+                first=True,
+                ignore_remembered=True,
                 ignore_requires_python=True,
                 save=False,
                 hooks=hooks,


Test patch:
diff --git a/tests/cli/test_init.py b/tests/cli/test_init.py
index 1e83460c..7078556f 100644
--- a/tests/cli/test_init.py
+++ b/tests/cli/test_init.py
@@ -79,7 +79,8 @@ def test_init_non_interactive(project_no_init, invoke, mocker):
     do_use.assert_called_once_with(
         project_no_init,
         ANY,
-        True,
+        first=True,
+        ignore_remembered=True,
         ignore_requires_python=True,
         save=False,
         hooks=ANY,