python-poetry / python-poetry/poetry
Add exclude options for `poetry new`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 34.3k
- Forks
- 2.5k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 30
Description
- I have searched the issues of this repo and believe that this is not a duplicate.
- I have searched the documentation and believe that my question is not covered.
Feature Request
Add exclude options for poetry new.
My usual workflow is as follows.
- Make a repo at GitHub and pull it to my local machine.
- Add python package with
poetry.
However,
poetry init is not enough.
poetry new returns FileExistsError since 1st step create .git and LICENSE,
I want to exclude .git and LICENSE from the poetry new limitation and utilize poetry new for 2nd step.
My proposal is as below.
- Add exclude to config in a form of a list.
exclud_pattern = ['.git', 'LICENSE']
- Modify check workflow in
src/poetry/console/commands/new.py
- if path.exists() and list(path.glob("*")):
+ glob_all = [str(p.relative_to(path)) for p in path.glob("*")]
+ if path.exists() and len(set(glob_all + exclude_pattern)) > len(exclude_pattern):
# Directory is not empty. Aborting.
raise RuntimeError(
f"Destination <fg=yellow>{path}</> exists and is not empty"
)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the poetry new entry point in src/poetry/console/commands/new.py and trace how destination contents are checked and how configuration is loaded. Define the exclusion behavior for existing .git and LICENSE entries, then verify that poetry new accepts those contents while still rejecting other non-empty destinations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100