diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 14fd8c6..00a1d28 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ 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 @@ -25,10 +25,11 @@ jobs: - 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: | @@ -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 diff --git a/poetry_dotenv_plugin/dotenv_plugin.py b/poetry_dotenv_plugin/dotenv_plugin.py index e248e86..05776c1 100644 --- a/poetry_dotenv_plugin/dotenv_plugin.py +++ b/poetry_dotenv_plugin/dotenv_plugin.py @@ -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") @@ -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", )