Commit graph

17 commits

Author SHA1 Message Date
Simon Willison
871038505b
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 <noreply@anthropic.com>
2025-12-16 19:34:45 -08:00
Simon Willison
6cd0fd2b4c Fix for Sphinx bug, closes #533, refs #531 2023-03-12 14:25:26 -07:00
Simon Willison
52ddb0b9ff
Rename utility functions to library 2022-11-15 07:53:38 -08:00
Simon Willison
6b268a1b36 language = "en" to fix Sphinx warning 2022-09-26 12:26:04 -07:00
Simon Willison
45e24deffe Link API docs to GitHub source code, refs #464 2022-08-13 09:24:18 -07:00
Simon Willison
5754311494
Only syntax highlight if a code-block is used
Refs #447
2022-06-21 08:00:17 -07:00
Simon Willison
59be60c471 Update copyright dates on docs 2022-05-20 14:57:49 -07:00
Simon Willison
2238e9baf9 sphinx-copybutton extension, closes #436 2022-05-20 14:57:26 -07:00
Simon Willison
397183debd Switch docs theme to Furo, refs #435 2022-05-20 14:52:00 -07:00
Simon Willison
26e6d2622c Use :param x: for docstring comments, refs #413 2022-03-11 09:39:17 -08:00
Simon Willison
6155da72c8
Add reference page to documentation using Sphinx autodoc (#312)
* Docstrings and type annotations for almost every method
* New /reference API documentation page using Sphink autodoc
* Custom Read The Docs config, to get autodoc working
* Fix for #313 (add_foreign_keys() doesn't reject being called with a View)
* Fixed #315 (.delete_where() returns [] when it should return self)
2021-08-10 16:09:28 -07:00
Simon Willison
e83aef951b New :issue: macro, closes #306 2021-08-02 14:29:16 -07:00
Simon Willison
0dca784dbe Release 3.1.1
Refs #209. Also updated copyright footer in documentation.
2021-01-01 15:56:20 -08:00
Simon Willison
65b2156d9c Show version in docs
Thanks, @nedbat

https://twitter.com/nedbat/status/1150490436114534400
2019-07-14 12:45:00 -07:00
Simon Willison
91311bb0db Sphinx docs now pull version info from git tag
Based on http://dreamiurg.net/2011/10/03/using-git-to-get-version-information/
2019-07-14 12:24:45 -07:00
Simon Willison
463fd3c3f6
Bump copyright year 2019-02-22 22:08:14 -08:00
Simon Willison
bd71be32ab Initial project layout + database table creation tools 2018-07-28 06:46:17 -07:00