diff options
author | Federico Caselli <cfederico87@gmail.com> | 2021-05-13 21:20:51 +0200 |
---|---|---|
committer | Federico Caselli <cfederico87@gmail.com> | 2021-05-16 11:11:10 +0200 |
commit | 71cb17c81d358646f8dfeac14e9662ce42bb94df (patch) | |
tree | 8ea3a686ffd0b9fea4fa7f91acfd8987d9369d9a /lib/sqlalchemy/sql | |
parent | 0d5508d77653b37368ff9de22307c154cc90cf71 (diff) | |
download | sqlalchemy-71cb17c81d358646f8dfeac14e9662ce42bb94df.tar.gz |
Remove pep484 type comments from the code
Current effort is around the stub package, and having typing in
two places makes thing worse, since the types here are usually
outdated compared to the version in the stubs.
Once v2 gets under way we can start consolidating the types
here.
Fixes: #6461
Change-Id: I7132a444bd7138123074bf5bc664b4bb119a85ce
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r-- | lib/sqlalchemy/sql/base.py | 8 | ||||
-rw-r--r-- | lib/sqlalchemy/sql/coercions.py | 16 | ||||
-rw-r--r-- | lib/sqlalchemy/sql/elements.py | 17 | ||||
-rw-r--r-- | lib/sqlalchemy/sql/selectable.py | 8 |
4 files changed, 10 insertions, 39 deletions
diff --git a/lib/sqlalchemy/sql/base.py b/lib/sqlalchemy/sql/base.py index 8ff907ef0..b7df927f1 100644 --- a/lib/sqlalchemy/sql/base.py +++ b/lib/sqlalchemy/sql/base.py @@ -27,12 +27,10 @@ from .. import util from ..util import HasMemoized from ..util import hybridmethod -if util.TYPE_CHECKING: - from types import ModuleType -coercions = None # type: ModuleType -elements = None # type: ModuleType -type_api = None # type: ModuleType +coercions = None +elements = None +type_api = None PARSE_AUTOCOMMIT = util.symbol("PARSE_AUTOCOMMIT") NO_ARG = util.symbol("NO_ARG") diff --git a/lib/sqlalchemy/sql/coercions.py b/lib/sqlalchemy/sql/coercions.py index 517bfd57d..36ac507ad 100644 --- a/lib/sqlalchemy/sql/coercions.py +++ b/lib/sqlalchemy/sql/coercions.py @@ -19,15 +19,13 @@ from .. import inspection from .. import util from ..util import collections_abc -if util.TYPE_CHECKING: - from types import ModuleType - -elements = None # type: ModuleType -lambdas = None # type: ModuleType -schema = None # type: ModuleType -selectable = None # type: ModuleType -sqltypes = None # type: ModuleType -traversals = None # type: ModuleType + +elements = None +lambdas = None +schema = None +selectable = None +sqltypes = None +traversals = None def _is_literal(element): diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py index 169a6d846..f212cb079 100644 --- a/lib/sqlalchemy/sql/elements.py +++ b/lib/sqlalchemy/sql/elements.py @@ -44,11 +44,6 @@ from .. import exc from .. import inspection from .. import util -if util.TYPE_CHECKING: - from typing import Any - from typing import Optional - from typing import Union - def collate(expression, collation): """Return the clause ``expression COLLATE collation``. @@ -422,7 +417,6 @@ class ClauseElement( ) def self_group(self, against=None): - # type: (Optional[Any]) -> ClauseElement """Apply a 'grouping' to this :class:`_expression.ClauseElement`. This method is overridden by subclasses to return a "grouping" @@ -792,7 +786,6 @@ class ColumnElement( _alt_names = () def self_group(self, against=None): - # type: (Optional[Any]) -> ClauseElement if ( against in (operators.and_, operators.or_, operators._asbool) and self.type._type_affinity is type_api.BOOLEANTYPE._type_affinity @@ -2074,7 +2067,6 @@ class TextClause( return self.type.comparator_factory(self) def self_group(self, against=None): - # type: (Optional[Any]) -> Union[Grouping, TextClause] if against is operators.in_op: return Grouping(self) else: @@ -2321,7 +2313,6 @@ class ClauseList( return list(itertools.chain(*[c._from_objects for c in self.clauses])) def self_group(self, against=None): - # type: (Optional[Any]) -> ClauseElement if self.group and operators.is_precedent(self.operator, against): return Grouping(self) else: @@ -2572,7 +2563,6 @@ class BooleanClauseList(ClauseList, ColumnElement): return (self,) def self_group(self, against=None): - # type: (Optional[Any]) -> ClauseElement if not self.clauses: return self else: @@ -3528,7 +3518,6 @@ class UnaryExpression(ColumnElement): return ClauseElement._negate(self) def self_group(self, against=None): - # type: (Optional[Any]) -> ClauseElement if self.operator and operators.is_precedent(self.operator, against): return Grouping(self) else: @@ -3654,7 +3643,6 @@ class AsBoolean(WrapsColumnExpression, UnaryExpression): return self.element def self_group(self, against=None): - # type: (Optional[Any]) -> ClauseElement return self def _negate(self): @@ -3736,7 +3724,6 @@ class BinaryExpression(ColumnElement): return self.left._from_objects + self.right._from_objects def self_group(self, against=None): - # type: (Optional[Any]) -> ClauseElement if operators.is_precedent(self.operator, against): return Grouping(self) @@ -3795,7 +3782,6 @@ class Slice(ColumnElement): self.type = type_api.NULLTYPE def self_group(self, against=None): - # type: (Optional[Any]) -> ClauseElement assert against is operator.getitem return self @@ -3813,7 +3799,6 @@ class GroupedElement(ClauseElement): __visit_name__ = "grouping" def self_group(self, against=None): - # type: (Optional[Any]) -> ClauseElement return self def _ungroup(self): @@ -4389,7 +4374,6 @@ class Label(roles.LabeledColumnExprRole, ColumnElement): return self._element.self_group(against=operators.as_) def self_group(self, against=None): - # type: (Optional[Any]) -> ClauseElement return self._apply_to_inner(self._element.self_group, against=against) def _negate(self): @@ -5116,7 +5100,6 @@ class _anonymous_label(_truncated_label): def safe_construct( cls, seed, body, enclosing_label=None, sanitize_key=False ): - # type: (int, str, Optional[_anonymous_label]) -> _anonymous_label if sanitize_key: body = re.sub(r"[%\(\) \$]+", "_", body).strip("_") diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py index 7007bb430..9ef9e1162 100644 --- a/lib/sqlalchemy/sql/selectable.py +++ b/lib/sqlalchemy/sql/selectable.py @@ -58,10 +58,6 @@ from .. import exc from .. import util from ..inspection import inspect -if util.TYPE_CHECKING: - from typing import Any - from typing import Optional - class _OffsetLimitParam(BindParameter): inherit_cache = True @@ -2796,7 +2792,6 @@ class SelectBase( is_select = True def _generate_fromclause_column_proxies(self, fromclause): - # type: (FromClause) -> None raise NotImplementedError() def _refresh_for_new_column(self, column): @@ -3080,7 +3075,6 @@ class SelectStatementGrouping(GroupedElement, SelectBase): _is_select_container = True def __init__(self, element): - # type: (SelectBase) -> None self.element = coercions.expect(roles.SelectStatementRole, element) def _ensure_disambiguated_names(self): @@ -3107,7 +3101,6 @@ class SelectStatementGrouping(GroupedElement, SelectBase): return self.element def self_group(self, against=None): - # type: (Optional[Any]) -> FromClause return self def _generate_fromclause_column_proxies(self, subquery): @@ -3877,7 +3870,6 @@ class CompoundSelect(HasCompileState, GenerativeSelect): return self.selects[0]._scalar_type() def self_group(self, against=None): - # type: (Optional[Any]) -> FromClause return SelectStatementGrouping(self) def is_derived_from(self, fromclause): |