Skip to content

Commit 450a845

Browse files
chore: add deptry dependency analysis check (#408)
Co-authored-by: Aaron <AJ> Steers <[email protected]>
1 parent 545e2ac commit 450a845

File tree

3 files changed

+198
-14
lines changed

3 files changed

+198
-14
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Dependency Analysis
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "airbyte_cdk/**"
9+
- "poetry.lock"
10+
- "pyproject.toml"
11+
pull_request:
12+
paths:
13+
- "airbyte_cdk/**"
14+
- "poetry.lock"
15+
- "pyproject.toml"
16+
17+
jobs:
18+
dependency-analysis:
19+
name: Dependency Analysis with Deptry
20+
runs-on: ubuntu-24.04
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
- name: Set up Python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: '3.10'
28+
- name: Set up Poetry
29+
uses: Gr1N/setup-poetry@v9
30+
with:
31+
poetry-version: "2.0.1"
32+
- name: Install dependencies
33+
run: poetry install --all-extras
34+
35+
# Job-specific step(s):
36+
- name: Run Deptry
37+
run: |
38+
poetry run deptry .

poetry.lock

Lines changed: 93 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 67 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,33 @@ isodate = "~0.6.1"
4040
Jinja2 = "~3.1.2"
4141
jsonref = "~0.2"
4242
jsonschema = "~4.17.3" # 4.18 has some significant breaking changes: https://github.com/python-jsonschema/jsonschema/releases/tag/v4.18.0
43+
packaging = "*" # Transitive dependency used directly in code
4344
pandas = "2.2.2"
44-
psutil = "6.1.0"
45+
psutil = "6.1.0" # TODO: Remove if unused
4546
pydantic = "^2.7"
4647
pyrate-limiter = "~3.1.0"
4748
python-dateutil = "^2.9.0"
4849
python-ulid = "^3.0.0"
4950
PyYAML = "^6.0.1"
50-
rapidfuzz = "^3.10.1"
51+
rapidfuzz = "^3.10.1" # TODO: Remove if unused
5152
requests = "*"
5253
requests_cache = "*"
54+
typing-extensions = "*" # Transitive dependency used directly in code
5355
wcmatch = "10.0"
5456
# Extras depedencies
55-
avro = { version = ">=1.11.2,<1.13.0", optional = true }
57+
avro = { version = ">=1.11.2,<1.13.0", optional = true } # TODO: Move into dev dependencies if only used in tests
5658
cohere = { version = "4.21", optional = true }
5759
fastavro = { version = "~1.8.0", optional = true }
5860
langchain = { version = "0.1.16", optional = true }
5961
langchain_core = { version = "0.1.42", optional = true }
60-
markdown = { version = "*", optional = true }
61-
openai = { version = "0.27.9", extras = ["embeddings"], optional = true }
62+
markdown = { version = "*", optional = true } # TODO: Remove if unused
63+
openai = { version = "0.27.9", extras = ["embeddings"], optional = true } # Used indirectly by langchain library
6264
pdf2image = { version = "1.16.3", optional = true }
63-
"pdfminer.six" = { version = "20221105", optional = true }
65+
"pdfminer.six" = { version = "20221105", optional = true } # Used indirectly by unstructured library
6466
pyarrow = { version = "^19.0.0", optional = true }
65-
pytesseract = { version = "0.3.10", optional = true }
66-
python-calamine = { version = "0.2.3", optional = true }
67-
python-snappy = { version = "0.7.3", optional = true }
67+
pytesseract = { version = "0.3.10", optional = true } # Used indirectly by unstructured library
68+
python-calamine = { version = "0.2.3", optional = true } # TODO: Remove if unused
69+
python-snappy = { version = "0.7.3", optional = true } # TODO: remove if unused
6870
tiktoken = { version = "0.8.0", optional = true }
6971
nltk = { version = "3.9.1", optional = true }
7072
# This will ensure that even when you run poetry install or pip install, the compatible version of numpy will always be chosen.
@@ -73,7 +75,7 @@ numpy = "<2"
7375
unstructured = { version = "0.10.27", extras = ["docx", "pptx"], optional = true }
7476
"unstructured.pytesseract" = { version = ">=0.3.12", optional = true }
7577
pyjwt = "^2.8.0"
76-
cryptography = ">=44.0.0,<45.0.0"
78+
cryptography = ">=44.0.0,<45.0.0" # Constrained as transitive dependency due to a bug in newer versions
7779
pytz = "2024.2"
7880
orjson = "^3.10.7"
7981
serpyco-rs = "^1.10.2"
@@ -102,6 +104,7 @@ types-requests = "^2.32.0.20241016"
102104
types-python-dateutil = "^2.9.0.20241003"
103105
types-pyyaml = "^6.0.12.20240917"
104106
types-cachetools = "^5.5.0.20240820"
107+
deptry = "^0.23.0"
105108

106109
[tool.poetry.extras]
107110
file-based = ["avro", "fastavro", "pyarrow", "unstructured", "pdf2image", "pdfminer.six", "unstructured.pytesseract", "pytesseract", "markdown", "python-calamine", "python-snappy"]
@@ -196,3 +199,57 @@ optional_poetry_groups = ["dev"]
196199
poetry_extras = ["file-based", "vector-db-based"]
197200
poe_tasks = ["check-ci"]
198201
mount_docker_socket = true
202+
203+
[tool.deptry]
204+
exclude = [
205+
"bin",
206+
"docs",
207+
"unit_tests",
208+
]
209+
210+
[tool.deptry.per_rule_ignores]
211+
# This is a mapping of rules and package names to be ignored for that rule.
212+
213+
# DEP001: Project should not contain missing dependencies.
214+
# https://deptry.com/rules-violations/#missing-dependencies-dep001
215+
DEP001 = [
216+
# These are imported but not declared:
217+
"source_declarative_manifest" # Imported only in dynamic import tests, not in main code
218+
]
219+
220+
# DEP002: Project should not contain unused dependencies.
221+
# https://deptry.com/rules-violations/#missing-dependencies-dep002
222+
DEP002 = [
223+
"cryptography", # Constrained as transitive dependency due to a bug in newer versions
224+
225+
# TODO: Remove these dependencies if not needed:
226+
"avro", # Only imported in `unit_tests` code
227+
"psutil",
228+
"rapidfuzz",
229+
"cohere",
230+
"markdown",
231+
"openai",
232+
"pdf2image",
233+
"pdfminer.six",
234+
"pytesseract",
235+
"python-calamine",
236+
"python-snappy",
237+
"tiktoken",
238+
"unstructured.pytesseract",
239+
]
240+
241+
# DEP003: Project should not use transitive dependencies.
242+
# https://deptry.com/rules-violations/#transitive-dependencies-dep003
243+
DEP003 = [
244+
# Transitive dependencies that are imported directly
245+
"pydantic_core" # Pydantic internals, no need to define as separate dependency
246+
]
247+
248+
# DEP004: Project should not use development dependencies in non-development code.
249+
# https://deptry.com/rules-violations/#misplaced-development-dependencies-dep004
250+
DEP004 = [
251+
# The `airbyte_cdk.test.utils` module is main code.
252+
# TODO: These should probably be declared within a `tests` extra:
253+
"pytest",
254+
"requests_mock",
255+
]

0 commit comments

Comments
 (0)