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

Fix poetry plugin crash on windows when outside of project #81

Merged
merged 1 commit into from
Jul 17, 2022
Merged
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
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Installation

.. code-block:: bash

poetry self add poethepoet[poetry_plugin]
poetry self add 'poethepoet[poetry_plugin]'

Enable tab completion for your shell
------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion poethepoet/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def find_pyproject_toml(self, target_dir: Optional[str] = None) -> Path:

maybe_result = self.cwd.joinpath(self.TOML_NAME)
while not maybe_result.exists():
if maybe_result.parent == Path("/"):
if len(maybe_result.parents) == 1:
raise PoeException(
f"Poe could not find a pyproject.toml file in {self.cwd} or"
" its parents"
Expand Down
17 changes: 17 additions & 0 deletions poethepoet/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,23 @@ def get_poe(cls, application: Application, io: IO):

class PoetryPlugin(ApplicationPlugin):
def activate(self, application: Application) -> None:
try:
return self._activate(application)
# pylint: disable=bare-except
except:
import os, sys

print(
"error: poethepoet plugin failed to activate. Set DEBUG_POE_PLUGIN=1 for details.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this print should be in an else branch of the if statement

file=sys.stderr,
)
if os.environ.get("DEBUG_POE_PLUGIN"):
import traceback

traceback.print_exc()
raise SystemExit(1)

def _activate(self, application: Application) -> None:
try:
poe_config = self._get_config(application)
except RuntimeError:
Expand Down