Skip to content

Commit

Permalink
improvement, python: make optional fields not required by default (#3041
Browse files Browse the repository at this point in the history
)

make optional fields not required by default
  • Loading branch information
armandobelardo authored Feb 22, 2024
1 parent fd48e66 commit 463e91e
Show file tree
Hide file tree
Showing 65 changed files with 194 additions and 166 deletions.
32 changes: 28 additions & 4 deletions generators/python/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,39 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

- Improvement: The Python SDK generator now defaults to `require_optional_fields = False`. This means that any requests that have optional fields no longer require a user to input data (or a `None` value) in.
Example:

```python
# Previously:
def my_function(my_parameter: typing.Optional[str]):
pass

my_function() # <--- This fails mypy
my_function(None) # <--- This is necessary
my_function("I work in both cases!")
...
# Now:
def my_function():
pass

my_function() # <--- I no longer fail mypy
my_function(None) # <--- I still work
my_function("I work in both cases!")
```

## [0.11.2] - 2024-02-21
- Improvement (Beta): The Python generator now supports a configuration option called `improved_imports`. To enable
this configuration, just add the following to your generators.yml

- Improvement (Beta): The Python generator now supports a configuration option called `improved_imports`. To enable
this configuration, just add the following to your generators.yml

```yaml
generators:
generators:
- name: fernapi/fern-python-sdk
...
config:
config:
improved_imports: true
```

Expand Down
2 changes: 1 addition & 1 deletion generators/python/sdk/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.11.2
0.11.2-rc0
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class SdkPydanticModelCustomConfig(PydanticModelCustomConfig):
smart_union: bool = True
include_union_utils: bool = False
wrapped_aliases: bool = False
require_optional_fields: bool = False


class SDKCustomConfig(pydantic.BaseModel):
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 463e91e

Please sign in to comment.