Skip to content

Commit aa83ff7

Browse files
feat: inheritance and reexport tests (#2)
* inheritance and reexport tests * Readme * Readme * Readme * Readme * Readme * Readme * Readme
1 parent e30d644 commit aa83ff7

File tree

10 files changed

+51
-3
lines changed

10 files changed

+51
-3
lines changed

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
<div align="center">
2-
32
<h1>
4-
<br/>env-example
3+
env-example
54
</h1>
6-
75
</div>
6+
<p align="center">
7+
<a href="https://pypi.org/project/fastapi" target="_blank">
8+
<img src="https://img.shields.io/pypi/v/env-example?color=%2334D058&label=pypi%20package" alt="Package version">
9+
</a>
10+
<a href="https://pypi.org/project/fastapi" target="_blank">
11+
<img src="https://github.com/jochemloedeman/env-example/actions/workflows/test.yml/badge.svg" alt="Package version">
12+
</a>
13+
</p>
14+
815

916
Creates an `.env.example` file for your monorepo, based on all [Pydantic settings](https://docs.pydantic.dev/latest/concepts/pydantic_settings/) classes found in your project. Env-example uses the abstract syntax tree of your project instead of runtime introspection, to avoid side effects and be less prone to import errors.
1017

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# ParentSettings
2+
PARENT_FIELD=
3+
4+
# ChildSettings
5+
CHILD_FIELD=

src/env_example/test_walk.py renamed to tests/cases/reexport_inheritance/project/package/__init__.py

File renamed without changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from pydantic_settings import BaseSettings
2+
3+
4+
class ParentSettings(BaseSettings):
5+
parent_field: int
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from package.reexporter import ParentSettings
2+
3+
4+
class ChildSettings(ParentSettings):
5+
child_field: str
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from package.base import ParentSettings
2+
3+
__all__ = ["ParentSettings"]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# ChildSettings
2+
CHILD_FIELD=
3+
4+
# GrandparentSettings
5+
GRANDPARENT_FIELD=
6+
7+
# ParentSettings
8+
PARENT_FIELD=

tests/cases/two_level_transitive_inheritance/project/package/__init__.py

Whitespace-only changes.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from pydantic_settings import BaseSettings
2+
3+
4+
class GrandparentSettings(BaseSettings):
5+
grandparent_field: int
6+
7+
8+
class ParentSettings(GrandparentSettings):
9+
parent_field: str
10+
11+
12+
class ChildSettings(ParentSettings):
13+
child_field: bool

tests/test_run.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
],
2525
),
2626
Case(name="transitive_inheritance", exclude_dirs=None),
27+
Case(name="two_level_transitive_inheritance", exclude_dirs=None),
28+
Case(name="reexport_inheritance", exclude_dirs=None),
2729
]
2830

2931

0 commit comments

Comments
 (0)