diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-01-09 11:49:02 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-01-24 15:14:01 -0500 |
commit | ff1ab665cb1694b85085680d1a02c7c11fa2a6d4 (patch) | |
tree | bb8414b44946d9cb96361d7dcd4a4541d8254672 /lib/sqlalchemy/sql/_py_util.py | |
parent | aba3ab247da4628e4e7baf993702e2efaccbc547 (diff) | |
download | sqlalchemy-ff1ab665cb1694b85085680d1a02c7c11fa2a6d4.tar.gz |
mypy: sqlalchemy.util
Starting to set up practices and conventions to
get the library typed.
Key goals for typing are:
1. whole library can pass mypy without any strict
turned on.
2. we can incrementally turn on some strict flags on a per-package/
module basis, as here we turn on more strictness for sqlalchemy.util, exc,
and log
3. mypy ORM plugin tests work fully without sqlalchemy2-stubs
installed
4. public facing methods all have return types, major parameter
signatures filled in also
5. Foundational elements like util etc. are typed enough so that
we can use them in fully typed internals higher up the stack.
Conventions set up here:
1. we can use lots of config in setup.cfg to limit where mypy
is throwing errors and how detailed it should be in different
packages / modules. We can use this to push up gerrits
that will pass tests fully without everything being typed.
2. a new tox target pep484 is added. this links to a new jenkins
pep484 job that works across all projects (alembic, dogpile, etc.)
We've worked around some mypy bugs that will likely
be around for awhile, and also set up some core practices
for how to deal with certain things such as public_factory
modules (mypy won't accept a module from a callable at all,
so need to use simple type checking conditionals).
References: #6810
Change-Id: I80be58029896a29fd9f491aa3215422a8b705e12
Diffstat (limited to 'lib/sqlalchemy/sql/_py_util.py')
-rw-r--r-- | lib/sqlalchemy/sql/_py_util.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/sqlalchemy/sql/_py_util.py b/lib/sqlalchemy/sql/_py_util.py index e9357bf7d..594967a40 100644 --- a/lib/sqlalchemy/sql/_py_util.py +++ b/lib/sqlalchemy/sql/_py_util.py @@ -5,8 +5,10 @@ # This module is part of SQLAlchemy and is released under # the MIT License: https://www.opensource.org/licenses/mit-license.php +from typing import Dict -class prefix_anon_map(dict): + +class prefix_anon_map(Dict[str, str]): """A map that creates new keys for missing key access. Considers keys of the form "<ident> <name>" to produce @@ -27,7 +29,7 @@ class prefix_anon_map(dict): return value -class cache_anon_map(dict): +class cache_anon_map(Dict[int, str]): """A map that creates new keys for missing key access. Produces an incrementing sequence given a series of unique keys. |