Skip to content

Commit

Permalink
fix(mypy): 1/2 mypy complains about conflicting main.py modules if we…
Browse files Browse the repository at this point in the history
… do not use unique names for the sample modules

ERROR:
```
samples/coffee-shop/main.py: error: Duplicate module named "main" (also at "./samples/basic-gemini/main.py")
samples/coffee-shop/main.py: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#mapping-file-paths-to-modules for more info
samples/coffee-shop/main.py: note: Common resolutions include: a) using `--exclude` to avoid checking one of them, b) adding `__init__.py` somewhere, c) using `--explicit-package-bases` or adjusting MYPYPATH
```

CHANGELOG:
- [ ] Use the same structure as other packages with unambiguous names
  for entry point modules to avoid collisions to satisfy mypy.
- [ ] Enable strict mypy checks by default; relax as necessary.
  • Loading branch information
yesudeep committed Feb 18, 2025
1 parent 082e26c commit 90fce12
Show file tree
Hide file tree
Showing 22 changed files with 132 additions and 661 deletions.
23 changes: 12 additions & 11 deletions py/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,20 @@ mypy_path = [
"plugins/ollama/src",
"plugins/pinecone/src",
"plugins/vertex-ai/src",
"samples/basic-gemini",
"samples/coffee-shop",
"samples/context-caching",
"samples/flow-sample1",
"samples/hello",
"samples/menu",
"samples/prompt-file",
"samples/rag",
"samples/vertex-ai-model-garden",
"samples/vertex-ai-reranker",
"samples/vertex-ai-vector-search",
"samples/basic-gemini/src",
"samples/coffee-shop/src",
"samples/context-caching/src",
"samples/flow-sample1/src",
"samples/hello/src",
"samples/menu/src",
"samples/prompt-file/src",
"samples/rag/src",
"samples/vertex-ai-model-garden/src",
"samples/vertex-ai-reranker/src",
"samples/vertex-ai-vector-search/src",
]
namespace_packages = true
strict = true
warn_unused_configs = true

[tool.datamodel-codegen]
Expand Down
12 changes: 12 additions & 0 deletions py/samples/basic-gemini/src/basic-gemini.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2025 Google LLC
# SPDX-License-Identifier: Apache-2.0

"""A stub for the sample to come."""


def main() -> None:
print('Hey')


if __name__ == '__main__':
main()
65 changes: 0 additions & 65 deletions py/samples/coffee-shop/main.py

This file was deleted.

12 changes: 12 additions & 0 deletions py/samples/coffee-shop/src/coffee-shop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2025 Google LLC
# SPDX-License-Identifier: Apache-2.0

"""A stub for the sample to come."""


def main() -> None:
print('Hey')


if __name__ == '__main__':
main()
65 changes: 0 additions & 65 deletions py/samples/context-caching/main.py

This file was deleted.

12 changes: 12 additions & 0 deletions py/samples/context-caching/src/context-caching.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2025 Google LLC
# SPDX-License-Identifier: Apache-2.0

"""A stub for the sample to come."""


def main() -> None:
print('Hey')


if __name__ == '__main__':
main()
65 changes: 0 additions & 65 deletions py/samples/flow-sample1/main.py

This file was deleted.

12 changes: 12 additions & 0 deletions py/samples/flow-sample1/src/flow-sample1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2025 Google LLC
# SPDX-License-Identifier: Apache-2.0

"""A stub for the sample to come."""


def main() -> None:
print('Hey')


if __name__ == '__main__':
main()
65 changes: 0 additions & 65 deletions py/samples/hello/main.py

This file was deleted.

File renamed without changes.
Loading

0 comments on commit 90fce12

Please sign in to comment.