Commit 08c1735
authored
Fix mypy Error on Python 3.11 (#563)
## Problem
The CI build was failing on Python 3.11 (but passing on Python 3.10) due
to a mypy error about an unused `# type: ignore` comment in
`pinecone/db_control/models/serverless_spec.py`. In Python 3.11,
`NotRequired` and `TypeAlias` are available in the standard `typing`
module, so mypy correctly flagged the type ignore comment as
unnecessary.
The code had an overly complex import structure with a try/except
fallback chain that attempted to import from `typing_extensions`, then
fall back to `typing`, then provide manual fallbacks. This was
unnecessary since `typing-extensions` is a required dependency and will
always be available.
## Solution
Simplified the import structure by:
1. Removing the unnecessary try/except fallback chain
2. Directly importing `NotRequired` and `TypeAlias` from
`typing_extensions` (which is always available as a dependency)
3. Removing the `if NotRequired is not None:` runtime check since
`NotRequired` will always be available
4. Removing all `# type: ignore` comments that are no longer needed
## Changes
### `pinecone/db_control/models/serverless_spec.py`
- Replaced complex try/except import chain with direct import from
`typing_extensions`
- Removed runtime check for `NotRequired` availability
- Removed unnecessary `# type: ignore` comments
- Simplified `ReadCapacityDedicatedConfigDict` class definition (removed
conditional definition)
## Impact
- Fixes the CI build failure on Python 3.11
- Code is cleaner and easier to maintain
- No functional changes - the behavior remains identical
- Both Python 3.10 and 3.11 pass mypy type checking
## Breaking Changes
None. This is a code cleanup that maintains full backward compatibility.1 parent 2e430c1 commit 08c1735
File tree
2 files changed
+10
-34
lines changed- .github/workflows
- pinecone/db_control/models
2 files changed
+10
-34
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | 8 | | |
18 | 9 | | |
19 | 10 | | |
| |||
24 | 15 | | |
25 | 16 | | |
26 | 17 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
| 18 | + | |
| 19 | + | |
31 | 20 | | |
32 | | - | |
33 | | - | |
34 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
35 | 24 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
52 | 28 | | |
53 | 29 | | |
54 | 30 | | |
| |||
0 commit comments