Skip to content

Commit 28b3d22

Browse files
authored
Merge branch 'DeepLcom:main' into main
2 parents 26ef617 + 85aec74 commit 28b3d22

File tree

14 files changed

+828
-24
lines changed

14 files changed

+828
-24
lines changed

.bumpversion.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Configuration file for bumpversion GitHub action
22
# See https://github.com/callowayproject/bump-my-version
33
[tool.bumpversion]
4-
current_version = "1.28.0"
4+
current_version = "1.29.0"
55
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
66
serialize = ["{major}.{minor}.{patch}"]
77
search = "{current_version}"
@@ -23,4 +23,4 @@ replace = "\"{new_version}\" == deepl.__version__"
2323
[[tool.bumpversion.files]]
2424
filename = "pyproject.toml"
2525
search = "name = \"deepl\"\nversion = \"{current_version}\""
26-
replace = "name = \"deepl\"\nversion = \"{new_version}\""
26+
replace = "name = \"deepl\"\nversion = \"{new_version}\""

.github/workflows/bumpversion.yml

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# GitHub action to bump version, update changelog, and create pull request for review.
2+
3+
name: Bump Version
4+
run-name: Bump version (${{ inputs.bump-type }}) by @${{ github.actor }}
5+
6+
# Note: Enable GitHub Actions to create pull requests in repository settings:
7+
# Settings -> Actions -> General -> Workflow permissions -> Allow GitHub Actions to create and approve pull requests
8+
9+
permissions: {}
10+
11+
concurrency:
12+
group: bumpversion
13+
cancel-in-progress: false
14+
15+
on:
16+
workflow_dispatch:
17+
inputs:
18+
bump-type:
19+
description: 'Version bump type'
20+
required: true
21+
default: 'patch'
22+
type: choice
23+
options:
24+
- major
25+
- minor
26+
- patch
27+
fail-on-empty-changelog:
28+
description: 'Fail if changelog is empty'
29+
required: false
30+
default: true
31+
type: boolean
32+
33+
jobs:
34+
bump_version:
35+
runs-on: ubuntu-latest
36+
permissions:
37+
contents: write
38+
pull-requests: write
39+
40+
outputs:
41+
version: ${{ steps.bump.outputs.current-version }}
42+
pr-number: ${{ steps.create_pr.outputs.pull-request-number }}
43+
44+
steps:
45+
- name: Checkout repository
46+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 https://github.com/actions/checkout/releases/tag/v6.0.2
47+
with:
48+
token: ${{ secrets.GITHUB_TOKEN }}
49+
50+
- name: Setup Python environment
51+
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0 https://github.com/astral-sh/setup-uv/releases/tag/v7.6.0
52+
53+
- name: Install bump-my-version
54+
run: uv tool install bump-my-version
55+
56+
- name: Bump version
57+
id: bump
58+
shell: bash
59+
run: |
60+
echo "::notice::Bumping version with type: ${{ inputs.bump-type }}"
61+
bump-my-version bump ${{ inputs.bump-type }}
62+
63+
CURRENT_VERSION=$(bump-my-version show current_version)
64+
echo "current-version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
65+
echo "::notice::Current version: $CURRENT_VERSION"
66+
67+
- name: Update changelog
68+
id: changelog
69+
uses: release-flow/keep-a-changelog-action@74931dec7ecdbfc8e38ac9ae7e8dd84c08db2f32 # v3.0.0 https://github.com/release-flow/keep-a-changelog-action/releases/tag/v3.0.0
70+
with:
71+
command: bump
72+
version: ${{ inputs.bump-type }}
73+
keep-unreleased-section: true
74+
fail-on-empty-release-notes: ${{ inputs.fail-on-empty-changelog }}
75+
76+
- name: Query changelog for release notes
77+
id: query_changelog
78+
uses: release-flow/keep-a-changelog-action@74931dec7ecdbfc8e38ac9ae7e8dd84c08db2f32 # v3.0.0 https://github.com/release-flow/keep-a-changelog-action/releases/tag/v3.0.0
79+
with:
80+
command: query
81+
version: latest
82+
83+
- name: Create Pull Request
84+
id: create_pr
85+
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0 https://github.com/peter-evans/create-pull-request/releases/tag/v8.1.0
86+
with:
87+
commit-message: "chore: bump version to ${{ steps.bump.outputs.current-version }} (${{ inputs.bump-type }} bump)"
88+
title: "Bump version to ${{ steps.bump.outputs.current-version }} (${{ inputs.bump-type }} bump)"
89+
body: |
90+
This PR **${{ inputs.bump-type }}** bumps the version to `${{ steps.bump.outputs.current-version }}` and updates the changelog.
91+
92+
### Reviewer Checklist
93+
Please verify the following before merging:
94+
95+
- [ ] **Version bump type is appropriate**: Confirm that the `${{ inputs.bump-type }}` bump matches the nature of changes since the last version:
96+
- **Major**: Breaking changes or significant API modifications
97+
- **Minor**: New features or functionality additions (backward compatible)
98+
- **Patch**: Bug fixes, documentation updates, or minor improvements
99+
- **no bump necessary**: Changes only to tests, CI, documentation, or examples.
100+
101+
If the bump type is not appropriate, close the PR and re-run the workflow with the correct bump type.
102+
103+
- [ ] **Changelog accuracy**: Review that the changelog entries accurately reflect the changes being released, and are understandable to end users.
104+
105+
If not, edit the changelog before merging.
106+
107+
### Next Steps
108+
After merging this PR, **trigger a release** to publish version `${{ steps.bump.outputs.current-version }}`.
109+
110+
### Changelog (automatically extracted from Unreleased section)
111+
${{ steps.query_changelog.outputs.release-notes }}
112+
113+
---
114+
*This PR was automatically created by the Bump Version workflow*
115+
branch: bumpversion-${{ steps.bump.outputs.current-version }}
116+
token: ${{ secrets.GITHUB_TOKEN }}
117+
delete-branch: true
118+
119+
- name: Summary
120+
if: always()
121+
run: |
122+
echo "## Workflow Summary" >> $GITHUB_STEP_SUMMARY
123+
echo "- **Bump Type:** ${{ inputs.bump-type }}" >> $GITHUB_STEP_SUMMARY
124+
echo "- **Version:** ${{ steps.bump.outputs.current-version }}" >> $GITHUB_STEP_SUMMARY
125+
126+
if [[ "${{ steps.create_pr.outputs.pull-request-number }}" != "" ]]; then
127+
PR_NUMBER="${{ steps.create_pr.outputs.pull-request-number }}"
128+
PR_URL="https://github.com/${{ github.repository }}/pull/$PR_NUMBER"
129+
echo "- **Pull Request:** [#$PR_NUMBER]($PR_URL)" >> $GITHUB_STEP_SUMMARY
130+
echo "" >> $GITHUB_STEP_SUMMARY
131+
echo "### Next Steps" >> $GITHUB_STEP_SUMMARY
132+
echo "1. Review and merge [Pull Request #$PR_NUMBER]($PR_URL)" >> $GITHUB_STEP_SUMMARY
133+
echo "2. **Trigger a release** to publish version \`${{ steps.bump.outputs.current-version }}\`" >> $GITHUB_STEP_SUMMARY
134+
else
135+
echo "" >> $GITHUB_STEP_SUMMARY
136+
echo "### ⚠️ Warning" >> $GITHUB_STEP_SUMMARY
137+
echo "Pull request creation failed. Please check the workflow logs." >> $GITHUB_STEP_SUMMARY
138+
fi
139+
140+
echo "" >> $GITHUB_STEP_SUMMARY
141+
echo "### 📋 Workflow Details" >> $GITHUB_STEP_SUMMARY
142+
echo "- **Triggered by:** @${{ github.actor }}" >> $GITHUB_STEP_SUMMARY
143+
echo "- **Repository:** ${{ github.repository }}" >> $GITHUB_STEP_SUMMARY
144+
echo "- **Run ID:** [${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> $GITHUB_STEP_SUMMARY

CHANGELOG.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [1.29.0] - 2026-03-26
10+
### Added
11+
- Added new language constants from January 2026 API release of 81 new languages.
12+
- Added support for style rules CRUD endpoints in the `DeepLClient` class:
13+
`create_style_rule()`, `get_style_rule()`, `update_style_rule_name()`,
14+
`update_style_rule_configured_rules()`, and `delete_style_rule()`.
15+
- Added support for style rule custom instruction CRUD endpoints in the
16+
`DeepLClient` class: `create_style_rule_custom_instruction()`,
17+
`get_style_rule_custom_instruction()`,
18+
`update_style_rule_custom_instruction()`, and
19+
`delete_style_rule_custom_instruction()`.
20+
Please refer to the README for usage instructions.
21+
22+
### Changed
23+
- Updated formality tests to accept either formal or informal output when using default formality,
24+
since the default formality is automatic.
25+
926
## [1.28.0] - 2026-02-05
1027
### Changed
1128
- Updated three tests to be less flakey and reflect new behavior regarding the model type.
@@ -376,7 +393,8 @@ Version increased to avoid conflicts with old packages on PyPI.
376393
## [0.1.0] - 2021-07-26
377394
Initial version.
378395

379-
[Unreleased]: https://github.com/DeepLcom/deepl-python/compare/v1.28.0...HEAD
396+
[Unreleased]: https://github.com/DeepLcom/deepl-python/compare/v1.29.0...HEAD
397+
[1.29.0]: https://github.com/DeepLcom/deepl-python/compare/v1.28.0...v1.29.0
380398
[1.28.0]: https://github.com/DeepLcom/deepl-python/compare/v1.27.0...v1.28.0
381399
[1.27.0]: https://github.com/DeepLcom/deepl-python/compare/v1.26.0...v1.27.0
382400
[1.26.0]: https://github.com/DeepLcom/deepl-python/compare/v1.25.0...v1.26.0

README.md

Lines changed: 86 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -644,36 +644,112 @@ target language English (`"EN"`) supports translations to both American English
644644
### Style Rules
645645

646646
Style rules allow you to customize your translations using a managed, shared list
647-
of rules for style, formatting, and more. Multiple style rules can be stored with
647+
of rules for style, formatting, and more. Multiple style rules can be stored with
648648
your account, each with a user-specified name and a uniquely-assigned ID.
649649

650-
#### Creating and managing style rules
650+
#### Creating a style rule
651651

652-
Currently style rules must be created and managed in the DeepL UI via
653-
https://www.deepl.com/en/custom-rules. Full CRUD functionality via the APIs will
654-
come shortly.
652+
Use `create_style_rule()` to create a new style rule with a name and language
653+
code. You can optionally provide `configured_rules` and `custom_instructions`.
655654

656-
#### Listing all style rules
655+
```python
656+
style_rule = deepl_client.create_style_rule(
657+
name="My Style Rule",
658+
language="en",
659+
)
660+
print(f"Created: {style_rule.name} ({style_rule.style_id})")
661+
```
662+
663+
#### Retrieving and listing style rules
664+
665+
Use `get_style_rule()` to retrieve a single style rule by ID, or
666+
`get_all_style_rules()` to list all style rules.
657667

658668
`get_all_style_rules()` returns a list of `StyleRuleInfo` objects
659669
corresponding to all of your stored style rules. The method accepts optional
660670
parameters: `page` (page number for pagination, 0-indexed), `page_size` (number
661-
of items per page), and `detailed` (whether to include detailed configuration
662-
rules in the `configured_rules` property).
671+
of items per page), and `detailed`. When `True`, the response includes
672+
`configured_rules` and `custom_instructions` for each style rule. When `False`
673+
(default), these fields are omitted for faster responses.
663674

664675
```python
665-
# Get all style rules
676+
# Get a single style rule by ID
677+
style_rule = deepl_client.get_style_rule("YOUR_STYLE_ID")
678+
print(f"{style_rule.name} ({style_rule.language})")
679+
680+
# List all style rules
666681
style_rules = deepl_client.get_all_style_rules()
667682
for rule in style_rules:
668683
print(f"{rule.name} ({rule.style_id})")
669684

670-
# Get style rules with detailed configuration
685+
# List with detailed configuration
671686
style_rules = deepl_client.get_all_style_rules(detailed=True)
672687
for rule in style_rules:
673688
if rule.configured_rules:
674689
print(f" Number formatting: {rule.configured_rules.numbers}")
675690
```
676691

692+
#### Updating a style rule
693+
694+
Use `update_style_rule_name()` to rename a style rule, and
695+
`update_style_rule_configured_rules()` to update its configured rules.
696+
697+
```python
698+
# Update the name
699+
updated = deepl_client.update_style_rule_name("YOUR_STYLE_ID", "New Name")
700+
701+
# Update configured rules
702+
updated = deepl_client.update_style_rule_configured_rules(
703+
"YOUR_STYLE_ID",
704+
{"style_and_tone": {"formality": "formal"}},
705+
)
706+
```
707+
708+
#### Managing custom instructions
709+
710+
Custom instructions allow you to add free-text prompts to a style rule. Use
711+
`create_style_rule_custom_instruction()`, `get_style_rule_custom_instruction()`,
712+
`update_style_rule_custom_instruction()`, and
713+
`delete_style_rule_custom_instruction()` to manage them.
714+
715+
```python
716+
# Create a custom instruction
717+
instruction = deepl_client.create_style_rule_custom_instruction(
718+
"YOUR_STYLE_ID",
719+
label="Formal tone",
720+
prompt="Always use formal language",
721+
)
722+
print(f"Created instruction: {instruction.id}")
723+
724+
# Get a custom instruction
725+
instruction = deepl_client.get_style_rule_custom_instruction(
726+
"YOUR_STYLE_ID", instruction.id
727+
)
728+
729+
# Update a custom instruction
730+
updated = deepl_client.update_style_rule_custom_instruction(
731+
"YOUR_STYLE_ID",
732+
instruction.id,
733+
label="Updated label",
734+
prompt="Use very formal language",
735+
)
736+
737+
# Delete a custom instruction
738+
deepl_client.delete_style_rule_custom_instruction(
739+
"YOUR_STYLE_ID", instruction.id
740+
)
741+
```
742+
743+
#### Deleting a style rule
744+
745+
Use `delete_style_rule()` to delete a style rule by ID.
746+
747+
```python
748+
deepl_client.delete_style_rule("YOUR_STYLE_ID")
749+
```
750+
751+
#### Using a style rule in translations
752+
677753
Style rules can also be used with the command line interface for text translation:
678754

679755
```bash

0 commit comments

Comments
 (0)