Skip to content

Commit 8f0f893

Browse files
authored
Merge branch 'main' into CUST-4514-python-sdk-handle-non-json-responses-html-fastly-empty-etc-stemming-from-500-s
2 parents 58da633 + 0a65ea2 commit 8f0f893

File tree

10 files changed

+674
-10
lines changed

10 files changed

+674
-10
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[bumpversion]
22
commit = True
33
tag = True
4-
current_version = 6.11.1
4+
current_version = 6.13.0
55

66
[bumpversion:file:nylas/_client_sdk_version.py]

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
nylas-python Changelog
22
======================
33

4-
Unreleased
4+
v6.13.0
5+
----------
6+
* Fixed from field handling in messages.send() to properly map "from_" field to "from field
7+
* Fixed content_id handling for large inline attachments to use content_id as field name instead of generic file{index}
8+
9+
v6.12.0
510
----------
611
* Added Yahoo, Zoom, EWS as providers to models/auth.py
712
* Fixed grants.update() not using the correct "PATCH" method

Contributing.md

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,160 @@
33

44
The following is a set of guidelines for contributing to the Nylas Python SDK; these are guidelines, not rules, so please use your best judgement and feel free to propose changes to this document via pull request.
55

6+
# Development Setup
7+
8+
To get started contributing to this repository, you'll need to set up a local development environment. Follow these steps:
9+
10+
## Prerequisites
11+
12+
- Python 3.8 or higher (the project supports Python 3.8+)
13+
- Git
14+
- A GitHub account
15+
16+
## Setup Steps
17+
18+
### 1. Fork and Clone the Repository
19+
20+
```bash
21+
# Fork the repository on GitHub, then clone your fork
22+
git clone https://github.com/YOUR_USERNAME/nylas-python.git
23+
cd nylas-python
24+
25+
# Add the upstream repository as a remote
26+
git remote add upstream https://github.com/nylas/nylas-python.git
27+
```
28+
29+
### 2. Set Up Python Virtual Environment
30+
31+
We recommend using a virtual environment to isolate your development dependencies:
32+
33+
```bash
34+
# Create a virtual environment
35+
python3 -m venv .venv
36+
37+
# Activate the virtual environment
38+
# On macOS/Linux:
39+
source .venv/bin/activate
40+
41+
# On Windows:
42+
# .venv\Scripts\activate
43+
```
44+
45+
**Important**: If you encounter issues with `pip` not being available in the virtual environment, run:
46+
47+
```bash
48+
# Ensure pip is available in the virtual environment
49+
python -m ensurepip --upgrade
50+
```
51+
52+
### 3. Install Development Dependencies
53+
54+
Install the package in editable mode with all optional dependencies:
55+
56+
```bash
57+
# Install the package in development mode with all optional dependencies
58+
python -m pip install -e ".[test,docs,release]"
59+
60+
# Or install specific dependency groups as needed:
61+
# python -m pip install -e ".[test]" # For running tests
62+
# python -m pip install -e ".[docs]" # For building documentation
63+
# python -m pip install -e ".[release]" # For release management
64+
```
65+
66+
**Note**: We use `python -m pip` instead of just `pip` to ensure we're using the pip from the virtual environment.
67+
68+
### 4. Install Code Quality Tools
69+
70+
Install the linting and formatting tools used by the project:
71+
72+
```bash
73+
python -m pip install pylint black
74+
```
75+
76+
### 5. Verify Your Setup
77+
78+
Run the tests to make sure everything is working correctly:
79+
80+
```bash
81+
# Run the test suite
82+
python setup.py test
83+
84+
# Or run tests with pytest directly
85+
pytest
86+
87+
# Run with coverage
88+
pytest --cov=nylas tests/
89+
```
90+
91+
Check code formatting and linting:
92+
93+
```bash
94+
# Check code formatting (this will modify files)
95+
black .
96+
97+
# Run linting
98+
pylint nylas
99+
```
100+
101+
## Development Workflow
102+
103+
1. **Create a branch** for your feature or bug fix:
104+
```bash
105+
git checkout -b your-feature-branch
106+
```
107+
108+
2. **Make your changes** and write tests for any new functionality
109+
110+
3. **Run tests and linting**:
111+
```bash
112+
python setup.py test
113+
black .
114+
pylint nylas
115+
```
116+
117+
4. **Commit your changes** following [conventional commit practices](https://www.conventionalcommits.org/)
118+
119+
5. **Push to your fork** and create a pull request
120+
121+
## Project Structure
122+
123+
- `nylas/` - Main SDK source code
124+
- `tests/` - Test files
125+
- `examples/` - Example usage scripts
126+
- `scripts/` - Build and development scripts
127+
- `pyproject.toml` - Project configuration and dependencies
128+
- `setup.py` - Legacy setup file (still used for some operations)
129+
130+
## Running Tests
131+
132+
The project uses pytest for testing:
133+
134+
```bash
135+
# Run all tests
136+
pytest
137+
138+
# Run tests with coverage
139+
pytest --cov=nylas tests/
140+
141+
# Run specific test files
142+
pytest tests/test_specific_module.py
143+
144+
# Run tests matching a pattern
145+
pytest -k "test_pattern"
146+
```
147+
148+
## Documentation
149+
150+
To build the documentation locally:
151+
152+
```bash
153+
# Make sure you have docs dependencies installed
154+
pip install -e ".[docs]"
155+
156+
# Generate documentation (if there are scripts for this)
157+
python scripts/generate-docs.py
158+
```
159+
6160
# How to Ask a Question
7161

8162
If you have a question about how to use the Python SDK, please [create an issue](https://github.com/nylas/nylas-python/issues) and label it as a question. If you have more general questions about the Nylas Communications Platform, or the Nylas Email, Calendar, and Contacts API, please reach out to support@nylas.com to get help.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Inline Attachment Example
2+
3+
This example demonstrates how to send messages and drafts with inline attachments using the `content_id` field in the Nylas Python SDK.
4+
5+
## What This Example Shows
6+
7+
- How to create inline attachments with `content_id` for HTML emails
8+
- How the SDK properly handles `content_id` for large attachments (>3MB)
9+
- The difference between inline attachments and regular attachments
10+
- How to reference inline attachments in HTML email bodies using `cid:` syntax
11+
12+
## Key Features Demonstrated
13+
14+
### Content ID Usage
15+
When an attachment includes a `content_id` field, the SDK will use this as the field name in multipart form data instead of the generic `file{index}` pattern. This is crucial for inline attachments that need to be referenced in the email body.
16+
17+
### HTML Email with Inline Images
18+
The example shows how to:
19+
1. Set the `content_id` field in the attachment
20+
2. Reference the attachment in HTML using `src="cid:your-content-id"`
21+
3. Set appropriate inline properties (`is_inline: True`, `content_disposition: "inline"`)
22+
23+
### Large Attachment Handling
24+
For attachments larger than 3MB, the SDK automatically switches from JSON to multipart form data. With this fix, the `content_id` is now properly respected in the form field names.
25+
26+
## Running the Example
27+
28+
1. Set your Nylas API key:
29+
```bash
30+
export NYLAS_API_KEY='your-api-key-here'
31+
```
32+
33+
2. Update the grant ID and email addresses in the script
34+
35+
3. Run the example:
36+
```bash
37+
python inline_attachment_example.py
38+
```
39+
40+
## Important Notes
41+
42+
- **Content ID Format**: Use a unique identifier for each inline attachment (e.g., `"image1@example.com"`, `"logo"`, `"banner-image"`)
43+
- **HTML Reference**: Reference inline attachments in HTML using `src="cid:your-content-id"`
44+
- **Backward Compatibility**: Attachments without `content_id` still work as before using `file{index}` naming
45+
- **File Size Threshold**: The 3MB threshold determines whether JSON or form data is used for the request
46+
47+
## Expected Behavior
48+
49+
### Before the Fix (Problematic)
50+
```
51+
Form data fields:
52+
- message: (JSON payload)
53+
- file0: (inline image - content_id ignored)
54+
- file1: (regular attachment)
55+
```
56+
57+
### After the Fix (Correct)
58+
```
59+
Form data fields:
60+
- message: (JSON payload)
61+
- my-inline-image: (inline image - uses content_id)
62+
- file1: (regular attachment - fallback to file{index})
63+
```
64+
65+
This ensures that email clients can properly display inline images by matching the `content_id` in the HTML `cid:` reference with the multipart form field name.

0 commit comments

Comments
 (0)