astral-sh / rye

a Hassle-Free Python Experience
https://rye.astral.sh
MIT License
13.82k stars 467 forks source link

rye pin able to run outside of a python package #1240

Open rjhawar opened 4 months ago

rjhawar commented 4 months ago

Steps to Reproduce

  1. Run rye pin outside of the python package
  2. Command succeeds and creates a .python-version file outside the python package

Expected Result

Running the rye pin command should not succeed if no pyproject.toml file is detected.

Here where it can lead to confuses for new folks:

  1. Create a new project --> rye init new-project
  2. Forget to cd to new project
  3. Run rye pin ---> the command should not succeed

Actual Result

Rye pin should check to see if it is inside a python package (check if pyproject.toml file is present).

Version Info

rye 0.36.0 commit: 0.36.0 (12c024c7c 2024-07-07) platform: macos (aarch64) self-python: cpython@3.12.3 symlink support: true uv enabled: true

Stacktrace

No response

lorenzogatti commented 2 months ago

Confirmed on Windows 10, Rye 0.38.