Skip to content
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
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
- '3.12'
- '3.13'
- '3.14'
- '3.14t'
- 'pypy3.11'
fail-fast: false
runs-on: ${{ matrix.os.image }}
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ jobs:
args: --release --out dist --interpreter ${{ startsWith(matrix.python, 'pypy') && matrix.python || format('python{0}', matrix.python) }}
sccache: 'true'

- name: Build free-threaded wheels
uses: PyO3/maturin-action@04ac600d27cdf7a9a280dadf7147097c42b757ad # v1.50.1
if: ${{ !startsWith(matrix.python, 'pypy') }}
with:
target: ${{ matrix.target }}
manylinux: ${{ matrix.manylinux }}
args: --release --out dist --interpreter python3.14t
sccache: 'true'

- name: Upload wheels
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
Expand Down Expand Up @@ -101,6 +110,20 @@ jobs:
args: --release --out dist --interpreter ${{ startsWith(matrix.python, 'pypy') && matrix.python || format('python{0}', matrix.python) }}
sccache: 'true'

- name: Install free-threaded Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
if: ${{ !startsWith(matrix.python, 'pypy') }}
with:
python-version: '3.14t'

- name: Build free-threaded wheels
uses: PyO3/maturin-action@04ac600d27cdf7a9a280dadf7147097c42b757ad # v1.50.1
if: ${{ !startsWith(matrix.python, 'pypy') }}
with:
target: ${{ matrix.target }}
args: --release --out dist --interpreter python3.14t
sccache: 'true'

- name: Upload wheels
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
Expand Down Expand Up @@ -138,6 +161,20 @@ jobs:
args: --release --out dist --interpreter ${{ steps.setup-python.outputs.python-path }}
sccache: 'true'

- name: Install free-threaded Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
if: ${{ !startsWith(matrix.python, 'pypy') }}
with:
python-version: '3.14t'

- name: Build free-threaded wheels
uses: PyO3/maturin-action@04ac600d27cdf7a9a280dadf7147097c42b757ad # v1.50.1
if: ${{ !startsWith(matrix.python, 'pypy') }}
with:
target: ${{ matrix.target }}
args: --release --out dist --interpreter python3.14t
sccache: 'true'

- name: Upload wheels
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
Expand Down
32 changes: 32 additions & 0 deletions tests/unit/test_thread_safety.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from __future__ import annotations

import concurrent.futures
from pathlib import Path
from typing import TYPE_CHECKING

from deptry.imports.extract import get_imported_modules_from_list_of_files

if TYPE_CHECKING:
from deptry.imports.location import Location

ITERATIONS = 50
WORKERS = 8
FIXTURE_FILE = Path("tests/fixtures/some_imports.py")


def _extract_imports() -> dict[str, list[Location]]:
return get_imported_modules_from_list_of_files([FIXTURE_FILE])


def test_concurrent_import_extraction() -> None:
if not FIXTURE_FILE.exists():
return

expected = _extract_imports()

with concurrent.futures.ThreadPoolExecutor(max_workers=WORKERS) as pool:
futures = [pool.submit(_extract_imports) for _ in range(ITERATIONS)]
results = [f.result() for f in futures]

for result in results:
assert set(result.keys()) == set(expected.keys())