diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-11-09 09:13:44 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-11-09 15:02:29 -0500 |
| commit | ebb54e80a5a52d0cce4cba1abc21c707a42c2c73 (patch) | |
| tree | a72c7d810cffc60cd85d5c7118759ef6be8dae40 /lib/sqlalchemy/sql | |
| parent | 8745dcf3e167a68c4665255716eefe138c89a8d2 (diff) | |
| download | sqlalchemy-ebb54e80a5a52d0cce4cba1abc21c707a42c2c73.tar.gz | |
try to support mypy 0.990
mypy introduces a crash we need to work around, also
some new rules. It also has either a behavioral change
regarding how output is rendered in relationship to
files being within sys.path or not, so work around
that for test_mypy_plugin_py3k.py
References: https://github.com/python/mypy/issues/14027
Change-Id: I689c7fe27dc52abee932de9e0fb23b2a2eba76fa
Diffstat (limited to 'lib/sqlalchemy/sql')
| -rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 7 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/traversals.py | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/visitors.py | 2 |
3 files changed, 7 insertions, 4 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 704c0d19c..3e62cb350 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -1694,7 +1694,7 @@ class SQLCompiler(Compiled): # at all if the key were present in the parameters if autoinc_key in self.binds: - def autoinc_getter(lastrowid, parameters): + def _autoinc_getter(lastrowid, parameters): param_value = parameters.get(autoinc_key, lastrowid) if param_value is not None: # they supplied non-None parameter, use that. @@ -1706,6 +1706,9 @@ class SQLCompiler(Compiled): # use lastrowid return lastrowid + # work around mypy https://github.com/python/mypy/issues/14027 + autoinc_getter = _autoinc_getter + else: lastrowid_processor = None @@ -1727,7 +1730,7 @@ class SQLCompiler(Compiled): return row_fn( ( autoinc_getter(lastrowid, parameters) - if autoinc_getter + if autoinc_getter is not None else lastrowid ) if col is autoinc_col diff --git a/lib/sqlalchemy/sql/traversals.py b/lib/sqlalchemy/sql/traversals.py index 94e635740..135407321 100644 --- a/lib/sqlalchemy/sql/traversals.py +++ b/lib/sqlalchemy/sql/traversals.py @@ -565,7 +565,7 @@ class TraversalComparatorStrategy(HasTraversalDispatch, util.MemoizedSlots): assert right_attrname is not None dispatch = self.dispatch(left_visit_sym) - assert dispatch, ( + assert dispatch is not None, ( f"{self.__class__} has no dispatch for " f"'{self._dispatch_lookup[left_visit_sym]}'" ) diff --git a/lib/sqlalchemy/sql/visitors.py b/lib/sqlalchemy/sql/visitors.py index b550f8f28..737107844 100644 --- a/lib/sqlalchemy/sql/visitors.py +++ b/lib/sqlalchemy/sql/visitors.py @@ -553,7 +553,7 @@ class HasTraversalDispatch: names = [] for attrname, visit_sym in internal_dispatch: meth = self.dispatch(visit_sym) - if meth: + if meth is not None: visit_name = _dispatch_lookup[visit_sym] names.append((attrname, visit_name)) |
