Skip to content

Conversation

@kzrnm
Copy link
Contributor

@kzrnm kzrnm commented Jan 2, 2026

Fix #748

This PR allows env_prefix to be applied to aliases as well, without introducing any breaking changes.

docs/index.md Outdated
1. `env_prefix` will be ignored and the value will be read from `FooAlias` environment variable.


If you want to apply `env_prefix` to aliases as well, set `env_prefix_target='all'` or `env_prefix_target='alias'`, which applies `env_prefix` to alias fields too.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between all and alias?

docs/index.md Outdated
1. `env_prefix` will be ignored and the value will be read from `FooAlias` environment variable.


If you want to apply `env_prefix` to aliases as well, set `env_prefix_target='all'` or `env_prefix_target='alias'`, which applies `env_prefix` to alias fields too.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is mentioned in the docs that env_prefix does not apply to fields with alias.

please change that part of documentation

Image

@hramezani
Copy link
Member

We have to remove the old doc because by this change env_prefix can work with alias
#749 (comment)

@hramezani
Copy link
Member

Thanks @kzrnm

@hramezani hramezani merged commit 4b4fb72 into pydantic:main Jan 4, 2026
19 checks passed
@kzrnm kzrnm deleted the fix/env_prefix branch January 5, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

There is no way to apply env_prefix to aliases

2 participants