Commit 8710385
Type fixes now enforced by ty
* Fix type warning for pipe.stdout possibly being None
Add conditional check before calling .read() on pipe.stdout since
Popen can return None for stdout.
* Use ctx.meta instead of dynamic attribute for database cleanup
Click's Context.meta dictionary is the proper way to store arbitrary
data on the context object, avoiding type checker warnings about
dynamic attribute assignment.
* Add assert for tables.callback before calling
Click's callback attribute is typed as Optional[Callable], so add
assert to satisfy type checker that it's not None.
* Fix type errors in cli.py and db.py
- Add type annotation for Database.conn to fix context manager errors
- Convert exception objects to str() when raising ClickException
- Handle None return from find_spatialite() with proper error message
* Fix remaining type errors in cli.py
- Add typing import and type annotations for dict kwargs
- Use db.table() instead of db[] for extract command
- Fix missing str() conversion for exception
* Fix type errors in db.py
- Add type annotation for Database.conn
- Add type: ignore for optional sqlite_dump import
- Update execute/query parameter types to Sequence|Dict for sqlite3 compatibility
- Use getattr for fn.__name__ access to handle callables without __name__
- Handle None return from find_spatialite() with OSError
- Fix pk_values assignment to use local variable
* Add type: ignore for optional pysqlite3 and sqlean imports
These are alternative sqlite3 implementations that may not be installed.
* Fix type errors in tests and plugins
- Add type: ignore for monkey-patching Database.__init__ in conftest
- Fix CLI test to pass string "2" instead of integer to Click invoke
- Add type: ignore for optional sqlean import
- Fix add_geometry_column test to use "XY" instead of integer 2
- Add type: ignore for click.Context as context manager
- Add type: ignore for enable_fts test that intentionally omits argument
- Add type: ignore for sys._called_from_test dynamic attribute
- Fix rows_from_file test type error for intentional wrong argument
- Handle None from pm.get_hookcallers in plugins.py
* Use db.table() instead of db[] for Table-specific operations
Changes db[table] to db.table(table) in CLI commands where we know
we're working with tables, not views. This resolves most of the
Table | View disambiguation type warnings since db.table() returns
Table directly rather than Table | View.
* Fix remaining type warnings in sqlite_utils package
- Add assert for sniff_buffer not being None
- Handle cursor.fetchone() potentially returning None
- Use db.table() for counts_table and index_foreign_keys
- Add type: ignore for cursor union type in raw mode
* Ran Black
* Run ty in CI
* ty check sqlite_utils
* Skip running ty on Windows
---------
Co-authored-by: Claude Opus 4.5 <[email protected]>1 parent fd5b09f commit 8710385
File tree
13 files changed
+89
-68
lines changed- .github/workflows
- docs
- sqlite_utils
- tests
13 files changed
+89
-68
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
48 | 53 | | |
49 | 54 | | |
50 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
53 | | - | |
54 | | - | |
| 54 | + | |
| 55 | + | |
55 | 56 | | |
56 | | - | |
| 57 | + | |
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
| 297 | + | |
297 | 298 | | |
298 | 299 | | |
299 | 300 | | |
| |||
338 | 339 | | |
339 | 340 | | |
340 | 341 | | |
341 | | - | |
| 342 | + | |
342 | 343 | | |
343 | 344 | | |
344 | 345 | | |
| |||
366 | 367 | | |
367 | 368 | | |
368 | 369 | | |
369 | | - | |
| 370 | + | |
370 | 371 | | |
371 | 372 | | |
372 | 373 | | |
| |||
393 | 394 | | |
394 | 395 | | |
395 | 396 | | |
396 | | - | |
| 397 | + | |
397 | 398 | | |
398 | 399 | | |
399 | 400 | | |
| |||
496 | 497 | | |
497 | 498 | | |
498 | 499 | | |
499 | | - | |
| 500 | + | |
500 | 501 | | |
501 | 502 | | |
502 | 503 | | |
| |||
534 | 535 | | |
535 | 536 | | |
536 | 537 | | |
537 | | - | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
538 | 541 | | |
539 | | - | |
| 542 | + | |
540 | 543 | | |
541 | 544 | | |
542 | 545 | | |
| |||
571 | 574 | | |
572 | 575 | | |
573 | 576 | | |
574 | | - | |
| 577 | + | |
575 | 578 | | |
576 | 579 | | |
577 | 580 | | |
| |||
644 | 647 | | |
645 | 648 | | |
646 | 649 | | |
647 | | - | |
| 650 | + | |
648 | 651 | | |
649 | 652 | | |
650 | 653 | | |
| |||
705 | 708 | | |
706 | 709 | | |
707 | 710 | | |
708 | | - | |
| 711 | + | |
709 | 712 | | |
710 | 713 | | |
711 | 714 | | |
| |||
728 | 731 | | |
729 | 732 | | |
730 | 733 | | |
731 | | - | |
| 734 | + | |
732 | 735 | | |
733 | 736 | | |
734 | 737 | | |
| |||
750 | 753 | | |
751 | 754 | | |
752 | 755 | | |
753 | | - | |
| 756 | + | |
754 | 757 | | |
755 | 758 | | |
756 | 759 | | |
| |||
826 | 829 | | |
827 | 830 | | |
828 | 831 | | |
829 | | - | |
| 832 | + | |
830 | 833 | | |
831 | 834 | | |
832 | 835 | | |
| |||
1036 | 1039 | | |
1037 | 1040 | | |
1038 | 1041 | | |
| 1042 | + | |
1039 | 1043 | | |
1040 | 1044 | | |
1041 | 1045 | | |
1042 | 1046 | | |
1043 | 1047 | | |
1044 | 1048 | | |
1045 | | - | |
| 1049 | + | |
1046 | 1050 | | |
1047 | 1051 | | |
1048 | 1052 | | |
| |||
1146 | 1150 | | |
1147 | 1151 | | |
1148 | 1152 | | |
1149 | | - | |
| 1153 | + | |
1150 | 1154 | | |
1151 | 1155 | | |
1152 | 1156 | | |
| |||
1173 | 1177 | | |
1174 | 1178 | | |
1175 | 1179 | | |
1176 | | - | |
| 1180 | + | |
1177 | 1181 | | |
1178 | 1182 | | |
1179 | 1183 | | |
| |||
1636 | 1640 | | |
1637 | 1641 | | |
1638 | 1642 | | |
1639 | | - | |
| 1643 | + | |
1640 | 1644 | | |
1641 | 1645 | | |
1642 | 1646 | | |
| |||
1667 | 1671 | | |
1668 | 1672 | | |
1669 | 1673 | | |
1670 | | - | |
| 1674 | + | |
1671 | 1675 | | |
1672 | 1676 | | |
1673 | 1677 | | |
| |||
2028 | 2032 | | |
2029 | 2033 | | |
2030 | 2034 | | |
2031 | | - | |
| 2035 | + | |
2032 | 2036 | | |
2033 | | - | |
| 2037 | + | |
2034 | 2038 | | |
2035 | 2039 | | |
2036 | 2040 | | |
| |||
2119 | 2123 | | |
2120 | 2124 | | |
2121 | 2125 | | |
2122 | | - | |
| 2126 | + | |
| 2127 | + | |
2123 | 2128 | | |
2124 | 2129 | | |
2125 | 2130 | | |
| |||
2200 | 2205 | | |
2201 | 2206 | | |
2202 | 2207 | | |
2203 | | - | |
| 2208 | + | |
2204 | 2209 | | |
2205 | 2210 | | |
2206 | 2211 | | |
| |||
2612 | 2617 | | |
2613 | 2618 | | |
2614 | 2619 | | |
2615 | | - | |
| 2620 | + | |
2616 | 2621 | | |
2617 | 2622 | | |
2618 | | - | |
| 2623 | + | |
2619 | 2624 | | |
2620 | 2625 | | |
2621 | 2626 | | |
| |||
2656 | 2661 | | |
2657 | 2662 | | |
2658 | 2663 | | |
2659 | | - | |
| 2664 | + | |
2660 | 2665 | | |
2661 | 2666 | | |
2662 | 2667 | | |
2663 | 2668 | | |
2664 | 2669 | | |
2665 | | - | |
| 2670 | + | |
2666 | 2671 | | |
2667 | 2672 | | |
2668 | 2673 | | |
| |||
2803 | 2808 | | |
2804 | 2809 | | |
2805 | 2810 | | |
2806 | | - | |
| 2811 | + | |
2807 | 2812 | | |
2808 | 2813 | | |
2809 | 2814 | | |
| |||
3122 | 3127 | | |
3123 | 3128 | | |
3124 | 3129 | | |
3125 | | - | |
| 3130 | + | |
3126 | 3131 | | |
3127 | 3132 | | |
3128 | 3133 | | |
| |||
3212 | 3217 | | |
3213 | 3218 | | |
3214 | 3219 | | |
3215 | | - | |
| 3220 | + | |
3216 | 3221 | | |
3217 | 3222 | | |
3218 | 3223 | | |
| |||
3250 | 3255 | | |
3251 | 3256 | | |
3252 | 3257 | | |
3253 | | - | |
| 3258 | + | |
3254 | 3259 | | |
3255 | 3260 | | |
3256 | 3261 | | |
| |||
3361 | 3366 | | |
3362 | 3367 | | |
3363 | 3368 | | |
3364 | | - | |
| 3369 | + | |
| 3370 | + | |
| 3371 | + | |
| 3372 | + | |
3365 | 3373 | | |
3366 | 3374 | | |
3367 | 3375 | | |
| |||
0 commit comments