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

Improve type hints #25

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
7 changes: 4 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@ jobs:
strategy:
matrix:
os: [Ubuntu, MacOS]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
id: setup-python
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true

- name: Install poetry
run: |
Expand All @@ -45,7 +46,7 @@ jobs:
run: poetry config virtualenvs.in-project true

- name: Set up cache
uses: actions/cache@v3
uses: actions/cache@v4
id: cache
with:
path: .venv
Expand Down
21 changes: 10 additions & 11 deletions poetry_dotenv_plugin/dotenv_plugin.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
import os

from cleo.events.console_events import COMMAND
import dotenv
from cleo.events.console_command_event import ConsoleCommandEvent
from cleo.events.console_events import COMMAND
from cleo.events.event_dispatcher import EventDispatcher
from poetry.console.application import Application
from poetry.console.commands.env_command import EnvCommand
from poetry.plugins.application_plugin import ApplicationPlugin


class DotenvPlugin(ApplicationPlugin):
def activate(self, application):
application.event_dispatcher.add_listener(COMMAND, self.load_dotenv)
def activate(self, application: Application) -> None:
application.event_dispatcher.add_listener(COMMAND, self.load_dotenv) # type:ignore

def load_dotenv(
self,
event,
event_name,
dispatcher
):
self, event: ConsoleCommandEvent, event_name: str, dispatcher: EventDispatcher
) -> None:
POETRY_DONT_LOAD_ENV = bool(os.environ.get("POETRY_DONT_LOAD_ENV"))
command = event.command

if not isinstance(command, EnvCommand) or POETRY_DONT_LOAD_ENV:
if POETRY_DONT_LOAD_ENV or not isinstance(event.command, EnvCommand):
return

POETRY_DOTENV_LOCATION = os.environ.get("POETRY_DOTENV_LOCATION")
Expand All @@ -30,7 +29,7 @@ def load_dotenv(

path = POETRY_DOTENV_LOCATION or dotenv.find_dotenv(usecwd=True)
POETRY_DOTENV_DONT_OVERRIDE = os.environ.get("POETRY_DOTENV_DONT_OVERRIDE", "")
DOTENV_OVERRIDE = not POETRY_DOTENV_DONT_OVERRIDE.lower() in (
DOTENV_OVERRIDE = POETRY_DOTENV_DONT_OVERRIDE.lower() not in (
"true",
"1",
)
Expand Down