diff options
| author | Federico Caselli <cfederico87@gmail.com> | 2022-11-03 20:52:21 +0100 |
|---|---|---|
| committer | Federico Caselli <cfederico87@gmail.com> | 2022-11-16 23:03:04 +0100 |
| commit | 4eb4ceca36c7ce931ea65ac06d6ed08bf459fc66 (patch) | |
| tree | 4970cff3f78489a4a0066cd27fd4bae682402957 /lib/sqlalchemy/util | |
| parent | 3fc6c40ea77c971d3067dab0fdf57a5b5313b69b (diff) | |
| download | sqlalchemy-4eb4ceca36c7ce931ea65ac06d6ed08bf459fc66.tar.gz | |
Try running pyupgrade on the code
command run is "pyupgrade --py37-plus --keep-runtime-typing --keep-percent-format <files...>"
pyupgrade will change assert_ to assertTrue. That was reverted since assertTrue does not
exists in sqlalchemy fixtures
Change-Id: Ie1ed2675c7b11d893d78e028aad0d1576baebb55
Diffstat (limited to 'lib/sqlalchemy/util')
| -rw-r--r-- | lib/sqlalchemy/util/_collections.py | 9 | ||||
| -rw-r--r-- | lib/sqlalchemy/util/_concurrency_py3k.py | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/util/compat.py | 4 | ||||
| -rw-r--r-- | lib/sqlalchemy/util/langhelpers.py | 4 | ||||
| -rw-r--r-- | lib/sqlalchemy/util/topological.py | 3 |
5 files changed, 9 insertions, 13 deletions
diff --git a/lib/sqlalchemy/util/_collections.py b/lib/sqlalchemy/util/_collections.py index 54be2e4e5..22df74590 100644 --- a/lib/sqlalchemy/util/_collections.py +++ b/lib/sqlalchemy/util/_collections.py @@ -185,9 +185,7 @@ class Properties(Generic[_T]): return iter(list(self._data.values())) def __dir__(self) -> List[str]: - return dir(super(Properties, self)) + [ - str(k) for k in self._data.keys() - ] + return dir(super()) + [str(k) for k in self._data.keys()] def __add__(self, other: Properties[_F]) -> List[Union[_T, _F]]: return list(self) + list(other) # type: ignore @@ -477,8 +475,7 @@ def flatten_iterator(x: Iterable[_T]) -> Iterator[_T]: elem: _T for elem in x: if not isinstance(elem, str) and hasattr(elem, "__iter__"): - for y in flatten_iterator(elem): - yield y + yield from flatten_iterator(elem) else: yield elem @@ -504,7 +501,7 @@ class LRUCache(typing.MutableMapping[_KT, _VT]): capacity: int threshold: float - size_alert: Optional[Callable[["LRUCache[_KT, _VT]"], None]] + size_alert: Optional[Callable[[LRUCache[_KT, _VT]], None]] def __init__( self, diff --git a/lib/sqlalchemy/util/_concurrency_py3k.py b/lib/sqlalchemy/util/_concurrency_py3k.py index 969e8d92e..ec9463019 100644 --- a/lib/sqlalchemy/util/_concurrency_py3k.py +++ b/lib/sqlalchemy/util/_concurrency_py3k.py @@ -32,7 +32,7 @@ if typing.TYPE_CHECKING: dead: bool gr_context: Optional[Context] - def __init__(self, fn: Callable[..., Any], driver: "greenlet"): + def __init__(self, fn: Callable[..., Any], driver: greenlet): ... def throw(self, *arg: Any) -> Any: diff --git a/lib/sqlalchemy/util/compat.py b/lib/sqlalchemy/util/compat.py index 24f9bcf10..6517e381c 100644 --- a/lib/sqlalchemy/util/compat.py +++ b/lib/sqlalchemy/util/compat.py @@ -64,11 +64,11 @@ def inspect_getfullargspec(func: Callable[..., Any]) -> FullArgSpec: if inspect.ismethod(func): func = func.__func__ if not inspect.isfunction(func): - raise TypeError("{!r} is not a Python function".format(func)) + raise TypeError(f"{func!r} is not a Python function") co = func.__code__ if not inspect.iscode(co): - raise TypeError("{!r} is not a code object".format(co)) + raise TypeError(f"{co!r} is not a code object") nargs = co.co_argcount names = co.co_varnames diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py index 051a8c89e..8df4950a3 100644 --- a/lib/sqlalchemy/util/langhelpers.py +++ b/lib/sqlalchemy/util/langhelpers.py @@ -1522,7 +1522,7 @@ class classproperty(property): fget: Callable[[Any], Any] def __init__(self, fget: Callable[[Any], Any], *arg: Any, **kw: Any): - super(classproperty, self).__init__(fget, *arg, **kw) + super().__init__(fget, *arg, **kw) self.__doc__ = fget.__doc__ def __get__(self, obj: Any, cls: Optional[type] = None) -> Any: @@ -1793,7 +1793,7 @@ class _hash_limit_string(str): interpolated = (value % args) + ( " (this warning may be suppressed after %d occurrences)" % num ) - self = super(_hash_limit_string, cls).__new__(cls, interpolated) + self = super().__new__(cls, interpolated) self._hash = hash("%s_%d" % (value, hash(interpolated) % num)) return self diff --git a/lib/sqlalchemy/util/topological.py b/lib/sqlalchemy/util/topological.py index 620e3bbb7..96aa5db2f 100644 --- a/lib/sqlalchemy/util/topological.py +++ b/lib/sqlalchemy/util/topological.py @@ -72,8 +72,7 @@ def sort( """ for set_ in sort_as_subsets(tuples, allitems): - for s in set_: - yield s + yield from set_ def find_cycles( |
