Skip to content

Commit 678002b

Browse files
authored
Jon/several improvements (#174)
Apply project setup improvements related to pre-commit and mypy * Add TYPE_CHECKING for pinecone and weviate * Ruff format * Remove redundant check * Fix end-of-file-fixer * Improve pre-commit config * Improve pr.yaml * Fix pinecone type * Add CODEOWNERS
1 parent f4362b4 commit 678002b

File tree

9 files changed

+33
-28
lines changed

9 files changed

+33
-28
lines changed

Diff for: .github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @neo4j/team-gen-ai

Diff for: .github/workflows/pr.yaml

+2-3
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,13 @@ jobs:
3232
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
3333
- name: Install dependencies
3434
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
35-
run: poetry install --no-interaction --extras external_clients
35+
run: poetry install --no-interaction
3636
- name: Check format and linting
3737
run: |
38-
poetry run ruff check --select I .
3938
poetry run ruff check .
4039
poetry run ruff format --check .
4140
- name: Run strict mypy check
42-
run: poetry run mypy --strict --ignore-missing-imports --allow-subclassing-any --allow-untyped-calls .
41+
run: poetry run mypy .
4342
- name: Run unit tests and check coverage
4443
run: |
4544
poetry run coverage run -m pytest tests/unit

Diff for: .pre-commit-config.yaml

+16-18
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,31 @@ repos:
44
hooks:
55
- id: trailing-whitespace
66
- id: end-of-file-fixer
7-
- repo: https://github.com/pre-commit/mirrors-mypy
8-
rev: v1.10.0
9-
hooks:
10-
- id: mypy
11-
name: Mypy Type Check
12-
entry: mypy
13-
language: python
14-
types: [ python ]
15-
stages: [ commit, push ]
16-
args: [--strict, --ignore-missing-imports, --allow-subclassing-any, --allow-untyped-calls]
17-
additional_dependencies:
18-
- pytest
19-
- pydantic
20-
- neo4j
21-
- langchain_community
22-
- langchain_openai
237
- repo: local
248
hooks:
259
- id: ruff-lint-isort
2610
name: Ruff Lint Sort Imports
27-
entry: poetry run ruff check --select I .
11+
entry: poetry run ruff check .
2812
language: system
2913
types: [ python ]
3014
stages: [ commit, push ]
3115
- id: ruff-lint
3216
name: Ruff Lint Check
33-
entry: poetry run ruff format --check
17+
entry: poetry run ruff format --check .
18+
language: system
19+
types: [ python ]
20+
stages: [ commit, push ]
21+
- id: mypy
22+
name: Mypy Type Check
23+
entry: mypy .
3424
language: system
3525
types: [ python ]
3626
stages: [ commit, push ]
27+
pass_filenames: false
28+
args: [
29+
--strict,
30+
--ignore-missing-imports,
31+
--allow-untyped-calls,
32+
--allow-subclassing-any,
33+
--exclude='./docs/'
34+
]

Diff for: docs/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,4 +191,4 @@ xml:
191191
pseudoxml:
192192
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
193193
@echo
194-
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
194+
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."

Diff for: docs/source/types.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,4 @@ SchemaRelation
8181
SchemaConfig
8282
============
8383

84-
.. autoclass:: neo4j_graphrag.experimental.components.schema.SchemaConfig
84+
.. autoclass:: neo4j_graphrag.experimental.components.schema.SchemaConfig

Diff for: docs/source/user_guide_pipeline.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,4 @@ can be added to the canvas by setting `hide_unused_outputs` to `False`:
130130
Here is an example of final result:
131131

132132
.. image:: images/pipeline_full.png
133-
:alt: Pipeline visualisation
133+
:alt: Pipeline visualisation

Diff for: src/neo4j_graphrag/retrievers/external/pinecone/pinecone.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
from __future__ import annotations
1616

1717
import logging
18-
from typing import Any, Callable, Optional
18+
from typing import TYPE_CHECKING, Any, Callable, Optional
1919

2020
import neo4j
21-
from pinecone import Pinecone
2221
from pydantic import ValidationError
2322

2423
from neo4j_graphrag.embeddings.base import Embedder
@@ -41,6 +40,9 @@
4140
RetrieverResultItem,
4241
)
4342

43+
if TYPE_CHECKING:
44+
from pinecone import Pinecone
45+
4446
logger = logging.getLogger(__name__)
4547

4648

Diff for: src/neo4j_graphrag/retrievers/external/pinecone/types.py

+3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
from typing import Any, Callable, Optional, Union
1818

1919
import neo4j
20+
21+
2022
from pinecone import Pinecone
23+
2124
from pydantic import (
2225
BaseModel,
2326
ConfigDict,

Diff for: src/neo4j_graphrag/retrievers/external/weaviate/weaviate.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
from __future__ import annotations
1616

1717
import logging
18-
from typing import Any, Callable, Optional
18+
from typing import Any, Callable, Optional, TYPE_CHECKING
1919

2020
import neo4j
2121
import weaviate.classes as wvc
2222
from pydantic import ValidationError
23-
from weaviate.client import WeaviateClient
2423

2524
from neo4j_graphrag.embeddings.base import Embedder
2625
from neo4j_graphrag.exceptions import (
@@ -43,6 +42,9 @@
4342

4443
logger = logging.getLogger(__name__)
4544

45+
if TYPE_CHECKING:
46+
from weaviate.client import WeaviateClient
47+
4648

4749
class WeaviateNeo4jRetriever(ExternalRetriever):
4850
"""

0 commit comments

Comments
 (0)