Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

AssertionError when spawning shell with "virtualenvs.create" set to false

Aperta
#30 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python
Ambito
cli

Direzione di ricerca

Inizia leggendo poetry_plugin_shell/command.py in corrispondenza dell’assertion mostrata nel traceback, prestando particolare attenzione al controllo dell’ambiente in handle. Riproduci il caso con virtualenvs.create impostato su false e conferma l’AssertionError corrente. Il lavoro è completato quando l’attivazione della shell segnala che la creazione dell’ambiente virtuale è disabilitata invece di esporre l’assertion.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

When attempting to activate the shell in a project with the virtualenvs.create configuration set to false, an AssertionError is raised. While the error itself may not be inherently wrong (since Poetry is expecting a virtual environment), the error message should more clearly indicate that the virtualenvs.create setting has been disabled, preventing the creation of a virtual environment.

How to reproduce:

  1. Create a new project:

    $ poetry new env-issue
    Created package env_issue in env-issue
    $ cd env-issue/
    
  2. Disable virtual environment creation:

    poetry config virtualenvs.create false --local
    
  3. Attempt to activate the Poetry shell:

    $ poetry shell
    Skipping virtualenv creation, as specified in config file.
    Spawning shell within /usr
    
      AssertionError
    

Error traceback:

  at ~/.local/share/pipx/venvs/poetry/lib/python3.13/site-packages/poetry_plugin_shell/command.py:43 in handle
       39│         self.line(f"Spawning shell within {self.env.path}")
       40│ 
       41│         # Be sure that we have the right type of environment.
       42│         env = self.env
    →  43│         assert env.is_venv()
       44│         env = cast("VirtualEnv", env)
       45│ 
       46│         # Setting this to avoid spawning unnecessary nested shells
       47│         os.environ["POETRY_ACTIVE"] = "1"

Expected behavior:

The shell may indeed not be spawned, and that is correct. However, instead of the AssertionError, the error message should clearly indicate that the virtualenvs.create setting is disabled, which prevents Poetry from creating a virtual environment. A more descriptive message, such as "Virtual environment creation is disabled by the configuration," would help clarify the reason for the error.

Lingua principale
Python
Stelle
141
Fork
10
Merge medio
59m
PR unite (30g)
3

Preparare l'ambiente

Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di python-poetry/poetry-plugin-shell

Tutte le issue di python-poetry/poetry-plugin-shell

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.