Skip to content

Commit

Permalink
Merge pull request #20 from jordantshaw/develop
Browse files Browse the repository at this point in the history
Adding to readme and added contributing docs
  • Loading branch information
jordantshaw committed Jan 30, 2024
2 parents be7f5e1 + b799e47 commit 280b7bc
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
pip install -r requirements.txt
- name: Build package
run: python -m build
- name: Publish package
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ name: Test

on:
push:
branches: [ "main", "develop" ]
branches: [ "*" ]
pull_request:
branches: [ "main", "develop" ]
branches: [ "*" ]

jobs:
build:
Expand All @@ -27,7 +27,7 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
pip install -e .[test];
pip install -r requirements.txt;
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
Expand Down
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,23 @@ Currently, the following file formats are supported:
- `.json`
- `.ini`

## Using dotenv files
`pydantic-config` supports using dotenv files because `pydantic-settings` natively supports dotenv files.
To use a dotenv file in conjunction with the config files simply set `env_file` parameter in `SettingsConfig`.
The values in the dotenv file will take precedence over the values in the config files.

```python
class Settings(SettingsModel):
app_name: str = None
description: str = None

model_config = SettingsConfig(
env_file='.env',
config_file='config.toml',
)
```


## Requiring config files to load
Config files will attempt to be loaded from the specified file path. By default, if no file is found the file
will simply not be loaded (no error occurs). This may be useful if you want to specify config files that
Expand All @@ -110,8 +127,6 @@ If your configurations have existing `list` or `dict` variables the contents wil
this behavior and override the contents instead you can set the `config_merge` option to `False` in the settings
`Config` class.



```toml
# config.toml
[foo]
Expand Down
40 changes: 40 additions & 0 deletions contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Contributing

## Clone the repository
Fork the repository on GitHub and clone your fork locally.

```shell
# Clone your fork and cd into the repo directory
git clone https://github.com/<your-username>/pydantic-config.git
cd pydantic-config
```

## Virtual environment
Create an isolated environment using python's built-in `venv` library. In this example we will create the
virtual environment in the project root.

```shell
# Create a virtual environment called "venv"
python -m venv venv

# Activate the virtual environment
source ./venv/bin/activate
```

## Install dependencies
Install the required dependencies using the command below. This will install all of the
project dependencies listed in the `pyproject.toml` file and also install the pydantic-config
package in editable mode.

```bash
# Install dependencies in the requirements.txt file
pip install -r requirements.txt
```

## Testing with pytest
After making your changes to the code, be sure to run all of the tests to make sure none of the changes
made have broken anything

```shell
pytest
```
10 changes: 0 additions & 10 deletions environment.yml

This file was deleted.

14 changes: 0 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,6 @@ all = [
'pyyaml>=5.1',
'tomli>=2.0.0'
]
dev = [
'pytest',
'twine',
'build',
'pyyaml>=5.1',
'python-dotenv>=0.15.0',
'tomli>=2.0.0'
]
test = [
'pytest',
'pyyaml==5.1',
'python-dotenv>=0.15.0',
'tomli>=2.0.0'
]

[project.urls]
"Homepage" = "https://github.com/jordantshaw/pydantic-config"
Expand Down
13 changes: 13 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# main dependencies
-e .[all]

# dev dependenies
python-dotenv>=0.15.0

# test dependencies
pytest

# build dependencies
build
twine

0 comments on commit 280b7bc

Please sign in to comment.