From 8f030068a10bb5572d7ac1d356719206a155eb11 Mon Sep 17 00:00:00 2001 From: Wang Date: Tue, 8 Aug 2023 08:25:39 +0800 Subject: [PATCH 1/3] Add pre-commit for sapp to fix lint error before commit --- .github/workflows/lint.yml | 42 ++++++++------------------------------ .pre-commit-config.yaml | 13 ++++++++++++ 2 files changed, 22 insertions(+), 33 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 94e1b4b7..beaf4126 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -9,44 +9,20 @@ on: workflow_dispatch: jobs: - black: + lint-with-precommit: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - - - name: Install black - run: pip install black==22.3.0 - - - name: Run black - run: black --exclude 'stubs\/' --check --diff . - - usort: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - - - name: Install usort - run: pip install usort==1.0.2 - - - name: Run usort - run: usort diff . && usort check . - - flake8: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: "3.10" - - name: Install flake8 - run: pip install flake8 + - name: Setup pre-commit + run: pip install pre-commit - - name: Run flake8 - run: flake8 + - name: Run pre-commit + run: pre-commit run --all-files ESLint: runs-on: ubuntu-latest diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..2fde890c --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,13 @@ +repos: + - repo: https://github.com/pycqa/flake8 + rev: 6.1.0 + hooks: + - id: flake8 + - repo: https://github.com/facebook/usort + rev: v1.0.7 + hooks: + - id: usort + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 23.7.0 + hooks: + - id: black From 31562fb1cf25ebaa9ee0b8ab954a959542f11b97 Mon Sep 17 00:00:00 2001 From: Wang Date: Tue, 8 Aug 2023 08:28:21 +0800 Subject: [PATCH 2/3] Run pre-commit to fix lint error in sapp --- sapp/db_support.py | 13 +- sapp/filter.py | 1 - sapp/json_diagnostics.py | 2 +- sapp/models.py | 6 - sapp/pipeline/model_generator.py | 6 +- sapp/tests/cli_test.py | 1 - sapp/tests/fake_object_generator.py | 4 +- sapp/trace_graph.py | 2 +- sapp/trimmed_trace_graph.py | 5 +- sapp/ui/filters.py | 1 - sapp/ui/interactive.py | 2 +- stubs/sqlalchemy/__init__.pyi | 266 +++++++++--------- stubs/sqlalchemy/dialects/__init__.pyi | 16 +- stubs/sqlalchemy/dialects/mssql/__init__.pyi | 64 +++-- stubs/sqlalchemy/dialects/mssql/base.pyi | 30 +- stubs/sqlalchemy/dialects/mysql/__init__.pyi | 70 ++--- stubs/sqlalchemy/dialects/mysql/base.pyi | 96 +++---- .../dialects/mysql/mysqlconnector.pyi | 12 +- stubs/sqlalchemy/dialects/mysql/mysqldb.pyi | 10 +- stubs/sqlalchemy/dialects/mysql/oursql.pyi | 8 +- stubs/sqlalchemy/dialects/mysql/pyodbc.pyi | 6 +- stubs/sqlalchemy/dialects/mysql/zxjdbc.pyi | 8 +- .../dialects/postgresql/__init__.pyi | 95 ++++--- .../sqlalchemy/dialects/postgresql/array.pyi | 3 +- stubs/sqlalchemy/dialects/postgresql/base.pyi | 24 +- stubs/sqlalchemy/dialects/postgresql/ext.pyi | 2 +- .../sqlalchemy/dialects/postgresql/hstore.pyi | 4 +- stubs/sqlalchemy/engine/__init__.pyi | 46 +-- stubs/sqlalchemy/engine/base.pyi | 3 +- stubs/sqlalchemy/engine/interfaces.pyi | 3 +- stubs/sqlalchemy/engine/strategies.pyi | 1 + stubs/sqlalchemy/event/__init__.pyi | 17 +- stubs/sqlalchemy/ext/__init__.pyi | 26 +- stubs/sqlalchemy/ext/declarative/__init__.pyi | 24 +- stubs/sqlalchemy/orm/__init__.pyi | 70 +++-- stubs/sqlalchemy/orm/attributes.pyi | 44 +-- stubs/sqlalchemy/orm/dependency.pyi | 8 +- stubs/sqlalchemy/orm/descriptor_props.pyi | 8 +- stubs/sqlalchemy/orm/events.pyi | 4 + stubs/sqlalchemy/orm/interfaces.pyi | 20 +- stubs/sqlalchemy/orm/properties.pyi | 1 + stubs/sqlalchemy/orm/query.pyi | 2 +- stubs/sqlalchemy/orm/relationships.pyi | 17 +- stubs/sqlalchemy/orm/session.pyi | 2 +- stubs/sqlalchemy/orm/state.pyi | 18 +- stubs/sqlalchemy/orm/strategies.pyi | 2 + stubs/sqlalchemy/orm/util.pyi | 6 +- stubs/sqlalchemy/schema.pyi | 84 +++--- stubs/sqlalchemy/sql/__init__.pyi | 130 ++++----- stubs/sqlalchemy/sql/ddl.pyi | 6 +- stubs/sqlalchemy/sql/dml.pyi | 15 +- stubs/sqlalchemy/sql/elements.pyi | 10 +- stubs/sqlalchemy/sql/expression.pyi | 132 ++++----- stubs/sqlalchemy/sql/functions.pyi | 24 +- stubs/sqlalchemy/sql/operators.pyi | 3 +- stubs/sqlalchemy/sql/schema.pyi | 35 ++- stubs/sqlalchemy/sql/selectable.pyi | 28 +- stubs/sqlalchemy/sql/sqltypes.pyi | 29 +- stubs/sqlalchemy/sql/type_api.pyi | 22 +- stubs/sqlalchemy/types.pyi | 108 +++---- stubs/sqlalchemy/util/__init__.pyi | 256 +++++++++-------- stubs/sqlalchemy/util/_collections.pyi | 4 +- stubs/sqlalchemy/util/compat.pyi | 11 +- 63 files changed, 1049 insertions(+), 927 deletions(-) diff --git a/sapp/db_support.py b/sapp/db_support.py index 53dac017..de28ec62 100644 --- a/sapp/db_support.py +++ b/sapp/db_support.py @@ -8,18 +8,7 @@ import logging from collections import namedtuple from itertools import tee -from typing import ( - Any, - Dict, - Iterable, - Iterator, - List, - Optional, - Set, - Tuple, - Type, - Union, -) +from typing import Dict, Iterable, Iterator, List, Optional, Set, Tuple, Type, Union from munch import Munch from sqlalchemy import and_, Column, exc, inspect, or_, String, types diff --git a/sapp/filter.py b/sapp/filter.py index e90ad870..f8b6ed5d 100644 --- a/sapp/filter.py +++ b/sapp/filter.py @@ -121,7 +121,6 @@ def from_query( max_trace_length_to_sources: Optional[int], is_new_issue: Optional[bool], ) -> Filter: - restructured_features: List[Dict[str, Union[str, List[str]]]] = [] for filtering_condition in features or []: feature_entry = {} diff --git a/sapp/json_diagnostics.py b/sapp/json_diagnostics.py index 11868a0b..0595631b 100644 --- a/sapp/json_diagnostics.py +++ b/sapp/json_diagnostics.py @@ -128,7 +128,7 @@ def entries(self, search: str, pretty_print: bool = False) -> List[Dict[str, Any entries = [] for callable_name, entry_location in entry_locations.items(): - for (file_id, offset) in entry_location: + for file_id, offset in entry_location: path = lookup_table.file_index[file_id] errors = parser.get_json_from_file_offset(path, offset) diff --git a/sapp/models.py b/sapp/models.py index 66cf6962..6ec045a2 100644 --- a/sapp/models.py +++ b/sapp/models.py @@ -158,7 +158,6 @@ def process_result_value(self, value, dialect) -> IssueDBID: class IssueInstanceTraceFrameAssoc(Base, PrepareMixin, RecordMixin): - __tablename__ = "issue_instance_trace_frame_assoc" __table_args__ = BASE_TABLE_ARGS @@ -1105,7 +1104,6 @@ def merge(cls, session, items): class TraceFrameLeafAssoc(Base, PrepareMixin, RecordMixin): - __tablename__ = "trace_frame_message_assoc" __table_args__ = BASE_TABLE_ARGS @@ -1159,7 +1157,6 @@ class IssueInstanceFixInfo(Base, PrepareMixin, RecordMixin): class TraceFrame(Base, PrepareMixin, RecordMixin): - __tablename__ = "trace_frames" __table_args__ = ( Index("ix_traceframe_run_caller_port", "run_id", "caller_id", "caller_port"), @@ -1325,7 +1322,6 @@ def type_intervals_match_or_ignored( # of traces leading to some other leaf. TraceFrameAnnotationTraceFrameAssoc # contains the first hop towards that leaf.. class TraceFrameAnnotation(Base, PrepareMixin, RecordMixin): - __tablename__ = "trace_frame_annotations" __table_args__ = BASE_TABLE_ARGS @@ -1395,7 +1391,6 @@ class TraceFrameAnnotation(Base, PrepareMixin, RecordMixin): # IssueInstanceTraceFrameAssoc, which indicates the first hop trace frame from # the issue instance. class TraceFrameAnnotationTraceFrameAssoc(Base, PrepareMixin, RecordMixin): - __tablename__ = "trace_frame_annotation_trace_frame_assoc" __table_args__ = BASE_TABLE_ARGS @@ -1643,7 +1638,6 @@ class PrimaryKey(Base, PrimaryKeyBase): class PrimaryKeyGenerator(PrimaryKeyGeneratorBase): - PRIMARY_KEY: Type = PrimaryKey QUERY_CLASSES: Set[Type] = { diff --git a/sapp/pipeline/model_generator.py b/sapp/pipeline/model_generator.py index 497cb6da..52f650ac 100644 --- a/sapp/pipeline/model_generator.py +++ b/sapp/pipeline/model_generator.py @@ -138,7 +138,7 @@ def _get_minimum_trace_length( ) -> int: length = None for entry in entries: - for (_leaf, depth) in entry.leaves: + for _leaf, depth in entry.leaves: if length is None or length > depth: length = depth if length is not None: @@ -439,7 +439,7 @@ def _generate_raw_trace_frame( leaf_records = [] leaf_mapping_ids: Set[LeafMapping] = set() - for (leaf, depth) in leaves: + for leaf, depth in leaves: leaf_record = self._get_shared_text(leaf_kind, leaf) caller_leaf_id = self.graph.get_transform_normalized_caller_kind_id( leaf_record @@ -473,7 +473,7 @@ def _generate_raw_trace_frame( reachability=FrameReachability.UNREACHABLE, ) - for (leaf_record, depth) in leaf_records: + for leaf_record, depth in leaf_records: self.graph.add_trace_frame_leaf_assoc(trace_frame, leaf_record, depth) # Note that the "graph._trace_frame_leaf_assoc" table is really associated with diff --git a/sapp/tests/cli_test.py b/sapp/tests/cli_test.py index 0b445cff..1857efab 100644 --- a/sapp/tests/cli_test.py +++ b/sapp/tests/cli_test.py @@ -174,7 +174,6 @@ def test_previous_input(self, mock_analysis_output) -> None: def assert_successful_exit(result: Result) -> None: - assert result.exit_code == 0, ( f"Command did not exit successfully: {result}\n" # pyre-fixme diff --git a/sapp/tests/fake_object_generator.py b/sapp/tests/fake_object_generator.py index 535be331..d340aea1 100644 --- a/sapp/tests/fake_object_generator.py +++ b/sapp/tests/fake_object_generator.py @@ -120,7 +120,7 @@ def precondition( ) if self.graph: self.graph.add_trace_frame(trace_frame) - for (leaf, depth) in leaves: + for leaf, depth in leaves: # pyre-fixme[16]: `Optional` has no attribute # `add_trace_frame_leaf_assoc`. self.graph.add_trace_frame_leaf_assoc(trace_frame, leaf, depth) @@ -171,7 +171,7 @@ def postcondition( ) if self.graph: self.graph.add_trace_frame(trace_frame) - for (leaf, depth) in leaves: + for leaf, depth in leaves: # pyre-fixme[16]: `Optional` has no attribute # `add_trace_frame_leaf_assoc`. self.graph.add_trace_frame_leaf_assoc(trace_frame, leaf, depth) diff --git a/sapp/trace_graph.py b/sapp/trace_graph.py index 10c1d6a6..27428ff2 100644 --- a/sapp/trace_graph.py +++ b/sapp/trace_graph.py @@ -8,7 +8,7 @@ import logging import re from collections import defaultdict -from typing import Any, cast, DefaultDict, Dict, Iterable, List, Optional, Set, Tuple +from typing import cast, DefaultDict, Dict, Iterable, List, Optional, Set, Tuple from .bulk_saver import BulkSaver from .models import ( diff --git a/sapp/trimmed_trace_graph.py b/sapp/trimmed_trace_graph.py index 67770656..40b02aef 100644 --- a/sapp/trimmed_trace_graph.py +++ b/sapp/trimmed_trace_graph.py @@ -365,7 +365,6 @@ def _next_interval(self, interval: Interval, next_frame: TraceFrame) -> Interval def _recompute_trace_length_association( self, visited: Visited, initial_frame_ids: Set[int], leaf_kind: SharedTextKind ) -> int: - """Walks the traces starting at the initial frames with the initial corresponding kinds to recompute and store the minimum trace length from each reachable frame to the corresponding leaf.""" @@ -685,7 +684,7 @@ def _populate_issues_from_affected_conditions( # Conditions that call this may have originated from other issues, # keep searching for parent conditions leading to this one. - for (next_frame, frame_leaves) in self._get_predecessor_frames( + for next_frame, frame_leaves in self._get_predecessor_frames( graph, leaves, condition ): if len(frame_leaves) > 0: @@ -786,7 +785,7 @@ def _add_trace_frame(self, graph: TraceGraph, trace_frame: TraceFrame) -> None: self._populate_shared_text(graph, trace_frame.filename_id) self._populate_shared_text(graph, trace_frame.caller_id) self._populate_shared_text(graph, trace_frame.callee_id) - for (leaf_id, depth) in graph._trace_frame_leaf_assoc[trace_frame_id].items(): + for leaf_id, depth in graph._trace_frame_leaf_assoc[trace_frame_id].items(): leaf = graph._shared_texts[leaf_id] if leaf_id not in self._shared_texts: self.add_shared_text(leaf) diff --git a/sapp/ui/filters.py b/sapp/ui/filters.py index b0c3c3cb..86c29e9e 100644 --- a/sapp/ui/filters.py +++ b/sapp/ui/filters.py @@ -48,7 +48,6 @@ def all_filters(session: Session) -> List[Filter]: def save_filter(session: Session, filter: Filter) -> None: - existing = ( session.query(FilterRecord).filter(FilterRecord.name == filter.name).first() ) diff --git a/sapp/ui/interactive.py b/sapp/ui/interactive.py index ddec5ac5..23bd0d4b 100644 --- a/sapp/ui/interactive.py +++ b/sapp/ui/interactive.py @@ -774,7 +774,7 @@ def leaves( query = queries.leaves( session=session, kind=kind, run_id=self._current_run_id ) - for (_, name) in query: + for _, name in query: leaves[name] += 1 results: Iterable[Tuple[str, int]] diff --git a/stubs/sqlalchemy/__init__.pyi b/stubs/sqlalchemy/__init__.pyi index 8aad74bb..530477da 100644 --- a/stubs/sqlalchemy/__init__.pyi +++ b/stubs/sqlalchemy/__init__.pyi @@ -1,129 +1,139 @@ -from . import connectors as connectors -from . import databases as databases -from . import dialects as dialects -from . import engine as engine -from . import event as event -from . import events as events -from . import exc as exc -from . import ext as ext -from . import inspection as inspection -from . import interfaces as interfaces -from . import log as log -from . import orm as orm -from . import pool as pool -from . import processors as processors -from . import schema as schema -from . import sql as sql -from . import types as types -from . import util as util -from .engine import create_engine as create_engine -from .engine import engine_from_config as engine_from_config +from . import ( + connectors as connectors, + databases as databases, + dialects as dialects, + engine as engine, + event as event, + events as events, + exc as exc, + ext as ext, + inspection as inspection, + interfaces as interfaces, + log as log, + orm as orm, + pool as pool, + processors as processors, + schema as schema, + sql as sql, + types as types, + util as util, +) +from .engine import ( + create_engine as create_engine, + engine_from_config as engine_from_config, +) from .inspection import inspect as inspect -from .schema import BLANK_SCHEMA as BLANK_SCHEMA -from .schema import DDL as DDL -from .schema import CheckConstraint as CheckConstraint -from .schema import Column as Column -from .schema import ColumnDefault as ColumnDefault -from .schema import Constraint as Constraint -from .schema import DefaultClause as DefaultClause -from .schema import FetchedValue as FetchedValue -from .schema import ForeignKey as ForeignKey -from .schema import ForeignKeyConstraint as ForeignKeyConstraint -from .schema import Index as Index -from .schema import MetaData as MetaData -from .schema import PassiveDefault as PassiveDefault -from .schema import PrimaryKeyConstraint as PrimaryKeyConstraint -from .schema import Sequence as Sequence -from .schema import Table as Table -from .schema import ThreadLocalMetaData as ThreadLocalMetaData -from .schema import UniqueConstraint as UniqueConstraint -from .sql import alias as alias -from .sql import all_ as all_ -from .sql import and_ as and_ -from .sql import any_ as any_ -from .sql import asc as asc -from .sql import between as between -from .sql import bindparam as bindparam -from .sql import case as case -from .sql import cast as cast -from .sql import collate as collate -from .sql import column as column -from .sql import delete as delete -from .sql import desc as desc -from .sql import distinct as distinct -from .sql import except_ as except_ -from .sql import except_all as except_all -from .sql import exists as exists -from .sql import extract as extract -from .sql import false as false -from .sql import func as func -from .sql import funcfilter as funcfilter -from .sql import insert as insert -from .sql import intersect as intersect -from .sql import intersect_all as intersect_all -from .sql import join as join -from .sql import lateral as lateral -from .sql import literal as literal -from .sql import literal_column as literal_column -from .sql import modifier as modifier -from .sql import not_ as not_ -from .sql import null as null -from .sql import or_ as or_ -from .sql import outerjoin as outerjoin -from .sql import outparam as outparam -from .sql import over as over -from .sql import select as select -from .sql import subquery as subquery -from .sql import table as table -from .sql import tablesample as tablesample -from .sql import text as text -from .sql import true as true -from .sql import tuple_ as tuple_ -from .sql import type_coerce as type_coerce -from .sql import union as union -from .sql import union_all as union_all -from .sql import update as update -from .sql import within_group as within_group -from .types import ARRAY as ARRAY -from .types import BIGINT as BIGINT -from .types import BINARY as BINARY -from .types import BLOB as BLOB -from .types import BOOLEAN as BOOLEAN -from .types import CHAR as CHAR -from .types import CLOB as CLOB -from .types import DATE as DATE -from .types import DATETIME as DATETIME -from .types import DECIMAL as DECIMAL -from .types import FLOAT as FLOAT -from .types import INT as INT -from .types import INTEGER as INTEGER -from .types import JSON as JSON -from .types import NCHAR as NCHAR -from .types import NUMERIC as NUMERIC -from .types import NVARCHAR as NVARCHAR -from .types import REAL as REAL -from .types import SMALLINT as SMALLINT -from .types import TEXT as TEXT -from .types import TIME as TIME -from .types import TIMESTAMP as TIMESTAMP -from .types import VARBINARY as VARBINARY -from .types import VARCHAR as VARCHAR -from .types import BigInteger as BigInteger -from .types import Binary as Binary -from .types import Boolean as Boolean -from .types import Date as Date -from .types import DateTime as DateTime -from .types import Enum as Enum -from .types import Float as Float -from .types import Integer as Integer -from .types import Interval as Interval -from .types import LargeBinary as LargeBinary -from .types import Numeric as Numeric -from .types import PickleType as PickleType -from .types import SmallInteger as SmallInteger -from .types import String as String -from .types import Text as Text -from .types import Time as Time -from .types import TypeDecorator as TypeDecorator -from .types import Unicode as Unicode -from .types import UnicodeText as UnicodeText +from .schema import ( + BLANK_SCHEMA as BLANK_SCHEMA, + CheckConstraint as CheckConstraint, + Column as Column, + ColumnDefault as ColumnDefault, + Constraint as Constraint, + DDL as DDL, + DefaultClause as DefaultClause, + FetchedValue as FetchedValue, + ForeignKey as ForeignKey, + ForeignKeyConstraint as ForeignKeyConstraint, + Index as Index, + MetaData as MetaData, + PassiveDefault as PassiveDefault, + PrimaryKeyConstraint as PrimaryKeyConstraint, + Sequence as Sequence, + Table as Table, + ThreadLocalMetaData as ThreadLocalMetaData, + UniqueConstraint as UniqueConstraint, +) +from .sql import ( + alias as alias, + all_ as all_, + and_ as and_, + any_ as any_, + asc as asc, + between as between, + bindparam as bindparam, + case as case, + cast as cast, + collate as collate, + column as column, + delete as delete, + desc as desc, + distinct as distinct, + except_ as except_, + except_all as except_all, + exists as exists, + extract as extract, + false as false, + func as func, + funcfilter as funcfilter, + insert as insert, + intersect as intersect, + intersect_all as intersect_all, + join as join, + lateral as lateral, + literal as literal, + literal_column as literal_column, + modifier as modifier, + not_ as not_, + null as null, + or_ as or_, + outerjoin as outerjoin, + outparam as outparam, + over as over, + select as select, + subquery as subquery, + table as table, + tablesample as tablesample, + text as text, + true as true, + tuple_ as tuple_, + type_coerce as type_coerce, + union as union, + union_all as union_all, + update as update, + within_group as within_group, +) +from .types import ( + ARRAY as ARRAY, + BIGINT as BIGINT, + BigInteger as BigInteger, + BINARY as BINARY, + Binary as Binary, + BLOB as BLOB, + BOOLEAN as BOOLEAN, + Boolean as Boolean, + CHAR as CHAR, + CLOB as CLOB, + DATE as DATE, + Date as Date, + DATETIME as DATETIME, + DateTime as DateTime, + DECIMAL as DECIMAL, + Enum as Enum, + FLOAT as FLOAT, + Float as Float, + INT as INT, + INTEGER as INTEGER, + Integer as Integer, + Interval as Interval, + JSON as JSON, + LargeBinary as LargeBinary, + NCHAR as NCHAR, + NUMERIC as NUMERIC, + Numeric as Numeric, + NVARCHAR as NVARCHAR, + PickleType as PickleType, + REAL as REAL, + SMALLINT as SMALLINT, + SmallInteger as SmallInteger, + String as String, + TEXT as TEXT, + Text as Text, + TIME as TIME, + Time as Time, + TIMESTAMP as TIMESTAMP, + TypeDecorator as TypeDecorator, + Unicode as Unicode, + UnicodeText as UnicodeText, + VARBINARY as VARBINARY, + VARCHAR as VARCHAR, +) diff --git a/stubs/sqlalchemy/dialects/__init__.pyi b/stubs/sqlalchemy/dialects/__init__.pyi index a5b99f8c..e41dcc15 100644 --- a/stubs/sqlalchemy/dialects/__init__.pyi +++ b/stubs/sqlalchemy/dialects/__init__.pyi @@ -1,11 +1,13 @@ from .. import util -from . import firebird as firebird -from . import mssql as mssql -from . import mysql as mysql -from . import oracle as oracle -from . import postgresql as postgresql -from . import sqlite as sqlite -from . import sybase as sybase +from . import ( + firebird as firebird, + mssql as mssql, + mysql as mysql, + oracle as oracle, + postgresql as postgresql, + sqlite as sqlite, + sybase as sybase, +) registry: util.PluginLoader plugins: util.PluginLoader diff --git a/stubs/sqlalchemy/dialects/mssql/__init__.pyi b/stubs/sqlalchemy/dialects/mssql/__init__.pyi index 4fe524c6..2b1acac6 100644 --- a/stubs/sqlalchemy/dialects/mssql/__init__.pyi +++ b/stubs/sqlalchemy/dialects/mssql/__init__.pyi @@ -1,31 +1,33 @@ -from .base import BIGINT as BIGINT -from .base import BINARY as BINARY -from .base import BIT as BIT -from .base import CHAR as CHAR -from .base import DATE as DATE -from .base import DATETIME as DATETIME -from .base import DATETIME2 as DATETIME2 -from .base import DATETIMEOFFSET as DATETIMEOFFSET -from .base import DECIMAL as DECIMAL -from .base import FLOAT as FLOAT -from .base import IMAGE as IMAGE -from .base import INTEGER as INTEGER -from .base import MONEY as MONEY -from .base import NCHAR as NCHAR -from .base import NTEXT as NTEXT -from .base import NUMERIC as NUMERIC -from .base import NVARCHAR as NVARCHAR -from .base import REAL as REAL -from .base import ROWVERSION as ROWVERSION -from .base import SMALLDATETIME as SMALLDATETIME -from .base import SMALLINT as SMALLINT -from .base import SMALLMONEY as SMALLMONEY -from .base import SQL_VARIANT as SQL_VARIANT -from .base import TEXT as TEXT -from .base import TIME as TIME -from .base import TIMESTAMP as TIMESTAMP -from .base import TINYINT as TINYINT -from .base import UNIQUEIDENTIFIER as UNIQUEIDENTIFIER -from .base import VARBINARY as VARBINARY -from .base import VARCHAR as VARCHAR -from .base import XML as XML +from .base import ( + BIGINT as BIGINT, + BINARY as BINARY, + BIT as BIT, + CHAR as CHAR, + DATE as DATE, + DATETIME as DATETIME, + DATETIME2 as DATETIME2, + DATETIMEOFFSET as DATETIMEOFFSET, + DECIMAL as DECIMAL, + FLOAT as FLOAT, + IMAGE as IMAGE, + INTEGER as INTEGER, + MONEY as MONEY, + NCHAR as NCHAR, + NTEXT as NTEXT, + NUMERIC as NUMERIC, + NVARCHAR as NVARCHAR, + REAL as REAL, + ROWVERSION as ROWVERSION, + SMALLDATETIME as SMALLDATETIME, + SMALLINT as SMALLINT, + SMALLMONEY as SMALLMONEY, + SQL_VARIANT as SQL_VARIANT, + TEXT as TEXT, + TIME as TIME, + TIMESTAMP as TIMESTAMP, + TINYINT as TINYINT, + UNIQUEIDENTIFIER as UNIQUEIDENTIFIER, + VARBINARY as VARBINARY, + VARCHAR as VARCHAR, + XML as XML, +) diff --git a/stubs/sqlalchemy/dialects/mssql/base.pyi b/stubs/sqlalchemy/dialects/mssql/base.pyi index 26e263ed..c95d5f35 100644 --- a/stubs/sqlalchemy/dialects/mssql/base.pyi +++ b/stubs/sqlalchemy/dialects/mssql/base.pyi @@ -1,20 +1,22 @@ from typing import Any, Optional from ... import types as _sqltypes -from ...types import BIGINT as BIGINT -from ...types import BINARY as BINARY -from ...types import CHAR as CHAR -from ...types import DATE as DATE -from ...types import DATETIME as DATETIME -from ...types import DECIMAL as DECIMAL -from ...types import FLOAT as FLOAT -from ...types import INTEGER as INTEGER -from ...types import NCHAR as NCHAR -from ...types import NUMERIC as NUMERIC -from ...types import NVARCHAR as NVARCHAR -from ...types import SMALLINT as SMALLINT -from ...types import TEXT as TEXT -from ...types import VARCHAR as VARCHAR +from ...types import ( + BIGINT as BIGINT, + BINARY as BINARY, + CHAR as CHAR, + DATE as DATE, + DATETIME as DATETIME, + DECIMAL as DECIMAL, + FLOAT as FLOAT, + INTEGER as INTEGER, + NCHAR as NCHAR, + NUMERIC as NUMERIC, + NVARCHAR as NVARCHAR, + SMALLINT as SMALLINT, + TEXT as TEXT, + VARCHAR as VARCHAR, +) class REAL(_sqltypes.REAL): __visit_name__: str = ... diff --git a/stubs/sqlalchemy/dialects/mysql/__init__.pyi b/stubs/sqlalchemy/dialects/mysql/__init__.pyi index 19674d82..4ce09ea3 100644 --- a/stubs/sqlalchemy/dialects/mysql/__init__.pyi +++ b/stubs/sqlalchemy/dialects/mysql/__init__.pyi @@ -1,39 +1,41 @@ from typing import Any -from .base import BIGINT as BIGINT -from .base import BINARY as BINARY -from .base import BIT as BIT -from .base import BLOB as BLOB -from .base import BOOLEAN as BOOLEAN -from .base import CHAR as CHAR -from .base import DATE as DATE -from .base import DATETIME as DATETIME -from .base import DECIMAL as DECIMAL -from .base import DOUBLE as DOUBLE -from .base import ENUM as ENUM -from .base import FLOAT as FLOAT -from .base import INTEGER as INTEGER -from .base import JSON as JSON -from .base import LONGBLOB as LONGBLOB -from .base import LONGTEXT as LONGTEXT -from .base import MEDIUMBLOB as MEDIUMBLOB -from .base import MEDIUMINT as MEDIUMINT -from .base import MEDIUMTEXT as MEDIUMTEXT -from .base import NCHAR as NCHAR -from .base import NUMERIC as NUMERIC -from .base import NVARCHAR as NVARCHAR -from .base import REAL as REAL -from .base import SET as SET -from .base import SMALLINT as SMALLINT -from .base import TEXT as TEXT -from .base import TIME as TIME -from .base import TIMESTAMP as TIMESTAMP -from .base import TINYBLOB as TINYBLOB -from .base import TINYINT as TINYINT -from .base import TINYTEXT as TINYTEXT -from .base import VARBINARY as VARBINARY -from .base import VARCHAR as VARCHAR -from .base import YEAR as YEAR +from .base import ( + BIGINT as BIGINT, + BINARY as BINARY, + BIT as BIT, + BLOB as BLOB, + BOOLEAN as BOOLEAN, + CHAR as CHAR, + DATE as DATE, + DATETIME as DATETIME, + DECIMAL as DECIMAL, + DOUBLE as DOUBLE, + ENUM as ENUM, + FLOAT as FLOAT, + INTEGER as INTEGER, + JSON as JSON, + LONGBLOB as LONGBLOB, + LONGTEXT as LONGTEXT, + MEDIUMBLOB as MEDIUMBLOB, + MEDIUMINT as MEDIUMINT, + MEDIUMTEXT as MEDIUMTEXT, + NCHAR as NCHAR, + NUMERIC as NUMERIC, + NVARCHAR as NVARCHAR, + REAL as REAL, + SET as SET, + SMALLINT as SMALLINT, + TEXT as TEXT, + TIME as TIME, + TIMESTAMP as TIMESTAMP, + TINYBLOB as TINYBLOB, + TINYINT as TINYINT, + TINYTEXT as TINYTEXT, + VARBINARY as VARBINARY, + VARCHAR as VARCHAR, + YEAR as YEAR, +) from .mysqldb import dialect as dialect # This should stay here until we are sure we added all submodules, diff --git a/stubs/sqlalchemy/dialects/mysql/base.pyi b/stubs/sqlalchemy/dialects/mysql/base.pyi index c835a149..21faf060 100644 --- a/stubs/sqlalchemy/dialects/mysql/base.pyi +++ b/stubs/sqlalchemy/dialects/mysql/base.pyi @@ -7,55 +7,57 @@ from typing import Any, Optional from sqlalchemy.sql import compiler -from ... import schema as sa_schema -from ... import types as sqltypes -from ...engine import default as default -from ...engine import reflection as reflection -from ...sql import compiler as compiler -from ...sql import elements as elements -from ...types import BINARY as BINARY -from ...types import BLOB as BLOB -from ...types import BOOLEAN as BOOLEAN -from ...types import DATE as DATE -from ...types import VARBINARY as VARBINARY +from ... import schema as sa_schema, types as sqltypes +from ...engine import default as default, reflection as reflection +from ...sql import compiler as compiler, elements as elements +from ...types import ( + BINARY as BINARY, + BLOB as BLOB, + BOOLEAN as BOOLEAN, + DATE as DATE, + VARBINARY as VARBINARY, +) from ...util import topological as topological from . import reflection as _reflection -from .enumerated import ENUM as ENUM -from .enumerated import SET as SET -from .json import JSON as JSON -from .json import JSONIndexType as JSONIndexType -from .json import JSONPathType as JSONPathType -from .types import BIGINT as BIGINT -from .types import BIT as BIT -from .types import CHAR as CHAR -from .types import DATETIME as DATETIME -from .types import DECIMAL as DECIMAL -from .types import DOUBLE as DOUBLE -from .types import FLOAT as FLOAT -from .types import INTEGER as INTEGER -from .types import LONGBLOB as LONGBLOB -from .types import LONGTEXT as LONGTEXT -from .types import MEDIUMBLOB as MEDIUMBLOB -from .types import MEDIUMINT as MEDIUMINT -from .types import MEDIUMTEXT as MEDIUMTEXT -from .types import NCHAR as NCHAR -from .types import NUMERIC as NUMERIC -from .types import NVARCHAR as NVARCHAR -from .types import REAL as REAL -from .types import SMALLINT as SMALLINT -from .types import TEXT as TEXT -from .types import TIME as TIME -from .types import TIMESTAMP as TIMESTAMP -from .types import TINYBLOB as TINYBLOB -from .types import TINYINT as TINYINT -from .types import TINYTEXT as TINYTEXT -from .types import VARCHAR as VARCHAR -from .types import YEAR as YEAR -from .types import _FloatType as _FloatType -from .types import _IntegerType as _IntegerType -from .types import _MatchType as _MatchType -from .types import _NumericType as _NumericType -from .types import _StringType as _StringType +from .enumerated import ENUM as ENUM, SET as SET +from .json import ( + JSON as JSON, + JSONIndexType as JSONIndexType, + JSONPathType as JSONPathType, +) +from .types import ( + _FloatType as _FloatType, + _IntegerType as _IntegerType, + _MatchType as _MatchType, + _NumericType as _NumericType, + _StringType as _StringType, + BIGINT as BIGINT, + BIT as BIT, + CHAR as CHAR, + DATETIME as DATETIME, + DECIMAL as DECIMAL, + DOUBLE as DOUBLE, + FLOAT as FLOAT, + INTEGER as INTEGER, + LONGBLOB as LONGBLOB, + LONGTEXT as LONGTEXT, + MEDIUMBLOB as MEDIUMBLOB, + MEDIUMINT as MEDIUMINT, + MEDIUMTEXT as MEDIUMTEXT, + NCHAR as NCHAR, + NUMERIC as NUMERIC, + NVARCHAR as NVARCHAR, + REAL as REAL, + SMALLINT as SMALLINT, + TEXT as TEXT, + TIME as TIME, + TIMESTAMP as TIMESTAMP, + TINYBLOB as TINYBLOB, + TINYINT as TINYINT, + TINYTEXT as TINYTEXT, + VARCHAR as VARCHAR, + YEAR as YEAR, +) RESERVED_WORDS: Any = ... AUTOCOMMIT_RE: Any = ... diff --git a/stubs/sqlalchemy/dialects/mysql/mysqlconnector.pyi b/stubs/sqlalchemy/dialects/mysql/mysqlconnector.pyi index 0e131591..dc03af31 100644 --- a/stubs/sqlalchemy/dialects/mysql/mysqlconnector.pyi +++ b/stubs/sqlalchemy/dialects/mysql/mysqlconnector.pyi @@ -4,11 +4,13 @@ from typing import Any -from .base import BIT as BIT -from .base import MySQLCompiler as MySQLCompiler -from .base import MySQLDialect as MySQLDialect -from .base import MySQLExecutionContext as MySQLExecutionContext -from .base import MySQLIdentifierPreparer as MySQLIdentifierPreparer +from .base import ( + BIT as BIT, + MySQLCompiler as MySQLCompiler, + MySQLDialect as MySQLDialect, + MySQLExecutionContext as MySQLExecutionContext, + MySQLIdentifierPreparer as MySQLIdentifierPreparer, +) class MySQLExecutionContext_mysqlconnector(MySQLExecutionContext): def get_lastrowid(self): ... diff --git a/stubs/sqlalchemy/dialects/mysql/mysqldb.pyi b/stubs/sqlalchemy/dialects/mysql/mysqldb.pyi index 742b7950..137c19c7 100644 --- a/stubs/sqlalchemy/dialects/mysql/mysqldb.pyi +++ b/stubs/sqlalchemy/dialects/mysql/mysqldb.pyi @@ -1,9 +1,11 @@ from typing import Any, Optional -from .base import MySQLCompiler as MySQLCompiler -from .base import MySQLDialect as MySQLDialect -from .base import MySQLExecutionContext as MySQLExecutionContext -from .base import MySQLIdentifierPreparer as MySQLIdentifierPreparer +from .base import ( + MySQLCompiler as MySQLCompiler, + MySQLDialect as MySQLDialect, + MySQLExecutionContext as MySQLExecutionContext, + MySQLIdentifierPreparer as MySQLIdentifierPreparer, +) class MySQLExecutionContext_mysqldb(MySQLExecutionContext): @property diff --git a/stubs/sqlalchemy/dialects/mysql/oursql.pyi b/stubs/sqlalchemy/dialects/mysql/oursql.pyi index 31bbf9e9..fac93be0 100644 --- a/stubs/sqlalchemy/dialects/mysql/oursql.pyi +++ b/stubs/sqlalchemy/dialects/mysql/oursql.pyi @@ -4,9 +4,11 @@ from typing import Any, Optional -from .base import BIT as BIT -from .base import MySQLDialect as MySQLDialect -from .base import MySQLExecutionContext as MySQLExecutionContext +from .base import ( + BIT as BIT, + MySQLDialect as MySQLDialect, + MySQLExecutionContext as MySQLExecutionContext, +) class _oursqlBIT(BIT): def result_processor(self, dialect, coltype): ... diff --git a/stubs/sqlalchemy/dialects/mysql/pyodbc.pyi b/stubs/sqlalchemy/dialects/mysql/pyodbc.pyi index b99af15a..afa5382b 100644 --- a/stubs/sqlalchemy/dialects/mysql/pyodbc.pyi +++ b/stubs/sqlalchemy/dialects/mysql/pyodbc.pyi @@ -5,8 +5,10 @@ from typing import Any from ...connectors.pyodbc import PyODBCConnector as PyODBCConnector -from .base import MySQLDialect as MySQLDialect -from .base import MySQLExecutionContext as MySQLExecutionContext +from .base import ( + MySQLDialect as MySQLDialect, + MySQLExecutionContext as MySQLExecutionContext, +) class MySQLExecutionContext_pyodbc(MySQLExecutionContext): def get_lastrowid(self): ... diff --git a/stubs/sqlalchemy/dialects/mysql/zxjdbc.pyi b/stubs/sqlalchemy/dialects/mysql/zxjdbc.pyi index 8f29f569..3d0a30e3 100644 --- a/stubs/sqlalchemy/dialects/mysql/zxjdbc.pyi +++ b/stubs/sqlalchemy/dialects/mysql/zxjdbc.pyi @@ -5,9 +5,11 @@ from typing import Any from ...connectors.zxJDBC import ZxJDBCConnector as ZxJDBCConnector -from .base import BIT as BIT -from .base import MySQLDialect as MySQLDialect -from .base import MySQLExecutionContext as MySQLExecutionContext +from .base import ( + BIT as BIT, + MySQLDialect as MySQLDialect, + MySQLExecutionContext as MySQLExecutionContext, +) class _ZxJDBCBit(BIT): def result_processor(self, dialect, coltype): ... diff --git a/stubs/sqlalchemy/dialects/postgresql/__init__.pyi b/stubs/sqlalchemy/dialects/postgresql/__init__.pyi index 8d4470be..4679218a 100644 --- a/stubs/sqlalchemy/dialects/postgresql/__init__.pyi +++ b/stubs/sqlalchemy/dialects/postgresql/__init__.pyi @@ -1,52 +1,51 @@ from typing import Any as _AnyType -from .array import ARRAY as ARRAY -from .array import All as All -from .array import Any as Any -from .array import array as array -from .base import BIGINT as BIGINT -from .base import BIT as BIT -from .base import BOOLEAN as BOOLEAN -from .base import BYTEA as BYTEA -from .base import CHAR as CHAR -from .base import CIDR as CIDR -from .base import DATE as DATE -from .base import DOUBLE_PRECISION as DOUBLE_PRECISION -from .base import ENUM as ENUM -from .base import FLOAT as FLOAT -from .base import INET as INET -from .base import INTEGER as INTEGER -from .base import INTERVAL as INTERVAL -from .base import MACADDR as MACADDR -from .base import MONEY as MONEY -from .base import NUMERIC as NUMERIC -from .base import OID as OID -from .base import REAL as REAL -from .base import REGCLASS as REGCLASS -from .base import SMALLINT as SMALLINT -from .base import TEXT as TEXT -from .base import TIME as TIME -from .base import TIMESTAMP as TIMESTAMP -from .base import TSVECTOR as TSVECTOR -from .base import UUID as UUID -from .base import VARCHAR as VARCHAR -from .base import CreateEnumType as CreateEnumType -from .base import DropEnumType as DropEnumType -from .dml import Insert as Insert -from .dml import insert as insert -from .ext import ExcludeConstraint as ExcludeConstraint -from .ext import aggregate_order_by as aggregate_order_by -from .ext import array_agg as array_agg -from .hstore import HSTORE as HSTORE -from .hstore import hstore as hstore -from .json import JSON as JSON -from .json import JSONB as JSONB -from .json import json as json -from .ranges import DATERANGE as DATERANGE -from .ranges import INT4RANGE as INT4RANGE -from .ranges import INT8RANGE as INT8RANGE -from .ranges import NUMRANGE as NUMRANGE -from .ranges import TSRANGE as TSRANGE -from .ranges import TSTZRANGE as TSTZRANGE +from .array import All as All, Any as Any, ARRAY as ARRAY, array as array +from .base import ( + BIGINT as BIGINT, + BIT as BIT, + BOOLEAN as BOOLEAN, + BYTEA as BYTEA, + CHAR as CHAR, + CIDR as CIDR, + CreateEnumType as CreateEnumType, + DATE as DATE, + DOUBLE_PRECISION as DOUBLE_PRECISION, + DropEnumType as DropEnumType, + ENUM as ENUM, + FLOAT as FLOAT, + INET as INET, + INTEGER as INTEGER, + INTERVAL as INTERVAL, + MACADDR as MACADDR, + MONEY as MONEY, + NUMERIC as NUMERIC, + OID as OID, + REAL as REAL, + REGCLASS as REGCLASS, + SMALLINT as SMALLINT, + TEXT as TEXT, + TIME as TIME, + TIMESTAMP as TIMESTAMP, + TSVECTOR as TSVECTOR, + UUID as UUID, + VARCHAR as VARCHAR, +) +from .dml import Insert as Insert, insert as insert +from .ext import ( + aggregate_order_by as aggregate_order_by, + array_agg as array_agg, + ExcludeConstraint as ExcludeConstraint, +) +from .hstore import HSTORE as HSTORE, hstore as hstore +from .json import JSON as JSON, json as json, JSONB as JSONB +from .ranges import ( + DATERANGE as DATERANGE, + INT4RANGE as INT4RANGE, + INT8RANGE as INT8RANGE, + NUMRANGE as NUMRANGE, + TSRANGE as TSRANGE, + TSTZRANGE as TSTZRANGE, +) def __getattr__(attr: str) -> _AnyType: ... diff --git a/stubs/sqlalchemy/dialects/postgresql/array.pyi b/stubs/sqlalchemy/dialects/postgresql/array.pyi index 4ea668d4..4649ea62 100644 --- a/stubs/sqlalchemy/dialects/postgresql/array.pyi +++ b/stubs/sqlalchemy/dialects/postgresql/array.pyi @@ -1,5 +1,4 @@ -from typing import Any as _AnyType -from typing import Callable, Optional, Type, TypeVar, overload +from typing import Any as _AnyType, Callable, Optional, overload, Type, TypeVar from ... import types as _sqltypes from ...sql import expression diff --git a/stubs/sqlalchemy/dialects/postgresql/base.pyi b/stubs/sqlalchemy/dialects/postgresql/base.pyi index f2acfac6..8197f80c 100644 --- a/stubs/sqlalchemy/dialects/postgresql/base.pyi +++ b/stubs/sqlalchemy/dialects/postgresql/base.pyi @@ -1,17 +1,19 @@ from datetime import timedelta from typing import Any, Dict, Optional, Pattern, Set, Text, Type -from sqlalchemy.types import BIGINT as BIGINT -from sqlalchemy.types import BOOLEAN as BOOLEAN -from sqlalchemy.types import CHAR as CHAR -from sqlalchemy.types import DATE as DATE -from sqlalchemy.types import FLOAT as FLOAT -from sqlalchemy.types import INTEGER as INTEGER -from sqlalchemy.types import NUMERIC as NUMERIC -from sqlalchemy.types import REAL as REAL -from sqlalchemy.types import SMALLINT as SMALLINT -from sqlalchemy.types import TEXT as TEXT -from sqlalchemy.types import VARCHAR as VARCHAR +from sqlalchemy.types import ( + BIGINT as BIGINT, + BOOLEAN as BOOLEAN, + CHAR as CHAR, + DATE as DATE, + FLOAT as FLOAT, + INTEGER as INTEGER, + NUMERIC as NUMERIC, + REAL as REAL, + SMALLINT as SMALLINT, + TEXT as TEXT, + VARCHAR as VARCHAR, +) from ... import schema from ...engine import default, reflection diff --git a/stubs/sqlalchemy/dialects/postgresql/ext.pyi b/stubs/sqlalchemy/dialects/postgresql/ext.pyi index 48b0d452..09b123ed 100644 --- a/stubs/sqlalchemy/dialects/postgresql/ext.pyi +++ b/stubs/sqlalchemy/dialects/postgresql/ext.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional, Tuple, Type, TypeVar, Union, overload +from typing import Any, Dict, Optional, overload, Tuple, Type, TypeVar, Union from ...engine.base import Connection, Engine from ...sql import expression, functions, visitors diff --git a/stubs/sqlalchemy/dialects/postgresql/hstore.pyi b/stubs/sqlalchemy/dialects/postgresql/hstore.pyi index 59879811..9d173fee 100644 --- a/stubs/sqlalchemy/dialects/postgresql/hstore.pyi +++ b/stubs/sqlalchemy/dialects/postgresql/hstore.pyi @@ -1,8 +1,7 @@ from typing import Any, List, Mapping, Optional, Text, Type from ... import types as sqltypes -from ...sql import functions as sqlfunc -from ...sql import type_api +from ...sql import functions as sqlfunc, type_api from .array import ARRAY class HSTORE( @@ -14,6 +13,7 @@ class HSTORE( def __init__( self, text_type: Optional[type_api.TypeEngine[Text]] = ... ) -> None: ... + class Comparator(type_api.TypeEngine.Comparator): def has_key(self, other: Any): ... def has_all(self, other: Any): ... diff --git a/stubs/sqlalchemy/engine/__init__.pyi b/stubs/sqlalchemy/engine/__init__.pyi index 11e02c82..ce2df7f3 100644 --- a/stubs/sqlalchemy/engine/__init__.pyi +++ b/stubs/sqlalchemy/engine/__init__.pyi @@ -1,26 +1,32 @@ from typing import Any from . import default as default -from .base import Connection as Connection -from .base import Engine as Engine -from .base import NestedTransaction as NestedTransaction -from .base import RootTransaction as RootTransaction -from .base import Transaction as Transaction -from .base import TwoPhaseTransaction as TwoPhaseTransaction -from .interfaces import Compiled as Compiled -from .interfaces import Connectable as Connectable -from .interfaces import CreateEnginePlugin as CreateEnginePlugin -from .interfaces import Dialect as Dialect -from .interfaces import ExceptionContext as ExceptionContext -from .interfaces import ExecutionContext as ExecutionContext -from .interfaces import TypeCompiler as TypeCompiler -from .result import BaseRowProxy as BaseRowProxy -from .result import BufferedColumnResultProxy as BufferedColumnResultProxy -from .result import BufferedColumnRow as BufferedColumnRow -from .result import BufferedRowResultProxy as BufferedRowResultProxy -from .result import FullyBufferedResultProxy as FullyBufferedResultProxy -from .result import ResultProxy as ResultProxy -from .result import RowProxy as RowProxy +from .base import ( + Connection as Connection, + Engine as Engine, + NestedTransaction as NestedTransaction, + RootTransaction as RootTransaction, + Transaction as Transaction, + TwoPhaseTransaction as TwoPhaseTransaction, +) +from .interfaces import ( + Compiled as Compiled, + Connectable as Connectable, + CreateEnginePlugin as CreateEnginePlugin, + Dialect as Dialect, + ExceptionContext as ExceptionContext, + ExecutionContext as ExecutionContext, + TypeCompiler as TypeCompiler, +) +from .result import ( + BaseRowProxy as BaseRowProxy, + BufferedColumnResultProxy as BufferedColumnResultProxy, + BufferedColumnRow as BufferedColumnRow, + BufferedRowResultProxy as BufferedRowResultProxy, + FullyBufferedResultProxy as FullyBufferedResultProxy, + ResultProxy as ResultProxy, + RowProxy as RowProxy, +) def create_engine(*args: Any, **kwargs: Any) -> Engine: ... def engine_from_config( diff --git a/stubs/sqlalchemy/engine/base.pyi b/stubs/sqlalchemy/engine/base.pyi index 4f47348c..4c4fe69b 100644 --- a/stubs/sqlalchemy/engine/base.pyi +++ b/stubs/sqlalchemy/engine/base.pyi @@ -6,8 +6,7 @@ from sqlalchemy.schema import DDLElement, DefaultGenerator from sqlalchemy.sql.expression import ClauseElement from sqlalchemy.sql.functions import FunctionElement -from .interfaces import Connectable as Connectable -from .interfaces import ExceptionContext as ExceptionContext +from .interfaces import Connectable as Connectable, ExceptionContext as ExceptionContext from .result import ResultProxy class Transaction(object): diff --git a/stubs/sqlalchemy/engine/interfaces.pyi b/stubs/sqlalchemy/engine/interfaces.pyi index 62ec8c72..acd37546 100644 --- a/stubs/sqlalchemy/engine/interfaces.pyi +++ b/stubs/sqlalchemy/engine/interfaces.pyi @@ -4,8 +4,7 @@ from sqlalchemy.schema import DDLElement, DefaultGenerator from sqlalchemy.sql.expression import ClauseElement from sqlalchemy.sql.functions import FunctionElement -from ..sql.compiler import Compiled as Compiled -from ..sql.compiler import TypeCompiler as TypeCompiler +from ..sql.compiler import Compiled as Compiled, TypeCompiler as TypeCompiler from .base import Connection from .result import ResultProxy diff --git a/stubs/sqlalchemy/engine/strategies.pyi b/stubs/sqlalchemy/engine/strategies.pyi index e0091d1c..7779f4e5 100644 --- a/stubs/sqlalchemy/engine/strategies.pyi +++ b/stubs/sqlalchemy/engine/strategies.pyi @@ -22,6 +22,7 @@ class ThreadLocalEngineStrategy(DefaultEngineStrategy): class MockEngineStrategy(EngineStrategy): name: str = ... def create(self, name_or_url, executor, **kwargs) -> MockEngineStrategy.MockConnection: ... # type: ignore + class MockConnection(base.Connectable): execute: Any = ... def __init__(self, dialect, execute) -> None: ... diff --git a/stubs/sqlalchemy/event/__init__.pyi b/stubs/sqlalchemy/event/__init__.pyi index 5d74456f..beb5d6cc 100644 --- a/stubs/sqlalchemy/event/__init__.pyi +++ b/stubs/sqlalchemy/event/__init__.pyi @@ -1,9 +1,10 @@ -from .api import CANCEL as CANCEL -from .api import NO_RETVAL as NO_RETVAL -from .api import contains as contains -from .api import listen as listen -from .api import listens_for as listens_for -from .api import remove as remove +from .api import ( + CANCEL as CANCEL, + contains as contains, + listen as listen, + listens_for as listens_for, + NO_RETVAL as NO_RETVAL, + remove as remove, +) from .attr import RefCollection as RefCollection -from .base import Events as Events -from .base import dispatcher as dispatcher +from .base import dispatcher as dispatcher, Events as Events diff --git a/stubs/sqlalchemy/ext/__init__.pyi b/stubs/sqlalchemy/ext/__init__.pyi index 651d05e7..6680e3c8 100644 --- a/stubs/sqlalchemy/ext/__init__.pyi +++ b/stubs/sqlalchemy/ext/__init__.pyi @@ -1,12 +1,14 @@ -from . import associationproxy as associationproxy -from . import automap as automap -from . import baked as baked -from . import compiler as compiler -from . import declarative as declarative -from . import horizontal_shard as horizontal_shard -from . import hybrid as hybrid -from . import indexable as indexable -from . import instrumentation as instrumentation -from . import mutable as mutable -from . import orderinglist as orderinglist -from . import serializer as serializer +from . import ( + associationproxy as associationproxy, + automap as automap, + baked as baked, + compiler as compiler, + declarative as declarative, + horizontal_shard as horizontal_shard, + hybrid as hybrid, + indexable as indexable, + instrumentation as instrumentation, + mutable as mutable, + orderinglist as orderinglist, + serializer as serializer, +) diff --git a/stubs/sqlalchemy/ext/declarative/__init__.pyi b/stubs/sqlalchemy/ext/declarative/__init__.pyi index 3d38254f..c9a4fcb2 100644 --- a/stubs/sqlalchemy/ext/declarative/__init__.pyi +++ b/stubs/sqlalchemy/ext/declarative/__init__.pyi @@ -1,11 +1,13 @@ -from .api import AbstractConcreteBase as AbstractConcreteBase -from .api import ConcreteBase as ConcreteBase -from .api import DeclarativeMeta as DeclarativeMeta -from .api import DeferredReflection as DeferredReflection -from .api import as_declarative as as_declarative -from .api import comparable_using as comparable_using -from .api import declarative_base as declarative_base -from .api import declared_attr as declared_attr -from .api import has_inherited_table as has_inherited_table -from .api import instrument_declarative as instrument_declarative -from .api import synonym_for as synonym_for +from .api import ( + AbstractConcreteBase as AbstractConcreteBase, + as_declarative as as_declarative, + comparable_using as comparable_using, + ConcreteBase as ConcreteBase, + declarative_base as declarative_base, + DeclarativeMeta as DeclarativeMeta, + declared_attr as declared_attr, + DeferredReflection as DeferredReflection, + has_inherited_table as has_inherited_table, + instrument_declarative as instrument_declarative, + synonym_for as synonym_for, +) diff --git a/stubs/sqlalchemy/orm/__init__.pyi b/stubs/sqlalchemy/orm/__init__.pyi index aeffb38a..2f733986 100644 --- a/stubs/sqlalchemy/orm/__init__.pyi +++ b/stubs/sqlalchemy/orm/__init__.pyi @@ -1,39 +1,49 @@ from typing import Any, Optional from . import mapper as mapperlib -from .descriptor_props import ComparableProperty as ComparableProperty -from .descriptor_props import CompositeProperty as CompositeProperty -from .descriptor_props import SynonymProperty as SynonymProperty -from .interfaces import EXT_CONTINUE as EXT_CONTINUE -from .interfaces import EXT_STOP as EXT_STOP -from .interfaces import PropComparator as PropComparator -from .mapper import Mapper as Mapper -from .mapper import class_mapper as class_mapper -from .mapper import configure_mappers as configure_mappers -from .mapper import reconstructor as reconstructor -from .mapper import validates as validates +from .descriptor_props import ( + ComparableProperty as ComparableProperty, + CompositeProperty as CompositeProperty, + SynonymProperty as SynonymProperty, +) +from .interfaces import ( + EXT_CONTINUE as EXT_CONTINUE, + EXT_STOP as EXT_STOP, + PropComparator as PropComparator, +) +from .mapper import ( + class_mapper as class_mapper, + configure_mappers as configure_mappers, + Mapper as Mapper, + reconstructor as reconstructor, + validates as validates, +) from .properties import ColumnProperty as ColumnProperty -from .query import AliasOption as AliasOption -from .query import Bundle as Bundle -from .query import Query as Query -from .relationships import RelationshipProperty as RelationshipProperty -from .relationships import foreign as foreign -from .relationships import remote as remote +from .query import AliasOption as AliasOption, Bundle as Bundle, Query as Query +from .relationships import ( + foreign as foreign, + RelationshipProperty as RelationshipProperty, + remote as remote, +) from .scoping import scoped_session as scoped_session -from .session import Session as Session -from .session import make_transient as make_transient -from .session import make_transient_to_detached as make_transient_to_detached -from .session import object_session as object_session -from .session import sessionmaker as sessionmaker +from .session import ( + make_transient as make_transient, + make_transient_to_detached as make_transient_to_detached, + object_session as object_session, + Session as Session, + sessionmaker as sessionmaker, +) from .strategy_options import Load as Load -from .util import aliased as aliased -from .util import join as join -from .util import object_mapper as object_mapper -from .util import outerjoin as outerjoin -from .util import polymorphic_union as polymorphic_union -from .util import was_deleted as was_deleted -from .util import with_parent as with_parent -from .util import with_polymorphic as with_polymorphic +from .util import ( + aliased as aliased, + join as join, + object_mapper as object_mapper, + outerjoin as outerjoin, + polymorphic_union as polymorphic_union, + was_deleted as was_deleted, + with_parent as with_parent, + with_polymorphic as with_polymorphic, +) def create_session(bind: Optional[Any] = ..., **kwargs): ... diff --git a/stubs/sqlalchemy/orm/attributes.pyi b/stubs/sqlalchemy/orm/attributes.pyi index 0a711e80..934e272a 100644 --- a/stubs/sqlalchemy/orm/attributes.pyi +++ b/stubs/sqlalchemy/orm/attributes.pyi @@ -2,27 +2,29 @@ from collections import namedtuple from typing import Any, Optional from . import interfaces -from .base import ATTR_EMPTY as ATTR_EMPTY -from .base import ATTR_WAS_SET as ATTR_WAS_SET -from .base import CALLABLES_OK as CALLABLES_OK -from .base import INIT_OK as INIT_OK -from .base import LOAD_AGAINST_COMMITTED as LOAD_AGAINST_COMMITTED -from .base import NEVER_SET as NEVER_SET -from .base import NO_AUTOFLUSH as NO_AUTOFLUSH -from .base import NO_CHANGE as NO_CHANGE -from .base import NO_VALUE as NO_VALUE -from .base import NON_PERSISTENT_OK as NON_PERSISTENT_OK -from .base import PASSIVE_NO_FETCH as PASSIVE_NO_FETCH -from .base import PASSIVE_NO_FETCH_RELATED as PASSIVE_NO_FETCH_RELATED -from .base import PASSIVE_NO_INITIALIZE as PASSIVE_NO_INITIALIZE -from .base import PASSIVE_NO_RESULT as PASSIVE_NO_RESULT -from .base import PASSIVE_OFF as PASSIVE_OFF -from .base import PASSIVE_ONLY_PERSISTENT as PASSIVE_ONLY_PERSISTENT -from .base import PASSIVE_RETURN_NEVER_SET as PASSIVE_RETURN_NEVER_SET -from .base import RELATED_OBJECT_OK as RELATED_OBJECT_OK -from .base import SQL_OK as SQL_OK -from .base import instance_str as instance_str -from .base import state_str as state_str +from .base import ( + ATTR_EMPTY as ATTR_EMPTY, + ATTR_WAS_SET as ATTR_WAS_SET, + CALLABLES_OK as CALLABLES_OK, + INIT_OK as INIT_OK, + instance_str as instance_str, + LOAD_AGAINST_COMMITTED as LOAD_AGAINST_COMMITTED, + NEVER_SET as NEVER_SET, + NO_AUTOFLUSH as NO_AUTOFLUSH, + NO_CHANGE as NO_CHANGE, + NO_VALUE as NO_VALUE, + NON_PERSISTENT_OK as NON_PERSISTENT_OK, + PASSIVE_NO_FETCH as PASSIVE_NO_FETCH, + PASSIVE_NO_FETCH_RELATED as PASSIVE_NO_FETCH_RELATED, + PASSIVE_NO_INITIALIZE as PASSIVE_NO_INITIALIZE, + PASSIVE_NO_RESULT as PASSIVE_NO_RESULT, + PASSIVE_OFF as PASSIVE_OFF, + PASSIVE_ONLY_PERSISTENT as PASSIVE_ONLY_PERSISTENT, + PASSIVE_RETURN_NEVER_SET as PASSIVE_RETURN_NEVER_SET, + RELATED_OBJECT_OK as RELATED_OBJECT_OK, + SQL_OK as SQL_OK, + state_str as state_str, +) class QueryableAttribute( interfaces._MappedAttribute, interfaces.InspectionAttr, interfaces.PropComparator diff --git a/stubs/sqlalchemy/orm/dependency.pyi b/stubs/sqlalchemy/orm/dependency.pyi index 1980cba0..108a932c 100644 --- a/stubs/sqlalchemy/orm/dependency.pyi +++ b/stubs/sqlalchemy/orm/dependency.pyi @@ -2,9 +2,11 @@ from typing import Any from .. import exc as sa_exc from . import util as mapperutil -from .interfaces import MANYTOMANY as MANYTOMANY -from .interfaces import MANYTOONE as MANYTOONE -from .interfaces import ONETOMANY as ONETOMANY +from .interfaces import ( + MANYTOMANY as MANYTOMANY, + MANYTOONE as MANYTOONE, + ONETOMANY as ONETOMANY, +) class DependencyProcessor(object): prop: Any = ... diff --git a/stubs/sqlalchemy/orm/descriptor_props.pyi b/stubs/sqlalchemy/orm/descriptor_props.pyi index 62a918e0..9d541c39 100644 --- a/stubs/sqlalchemy/orm/descriptor_props.pyi +++ b/stubs/sqlalchemy/orm/descriptor_props.pyi @@ -1,8 +1,10 @@ from typing import Any, Optional from . import query -from .interfaces import MapperProperty as MapperProperty -from .interfaces import PropComparator as PropComparator +from .interfaces import ( + MapperProperty as MapperProperty, + PropComparator as PropComparator, +) class DescriptorProperty(MapperProperty): doc: Any = ... @@ -26,10 +28,12 @@ class CompositeProperty(DescriptorProperty): @property def columns(self): ... def get_history(self, state, dict_, passive: Any = ...): ... + class CompositeBundle(query.Bundle): property: Any = ... def __init__(self, property, expr) -> None: ... def create_row_processor(self, query, procs, labels): ... + class Comparator(PropComparator): __hash__: Any = ... @property diff --git a/stubs/sqlalchemy/orm/events.pyi b/stubs/sqlalchemy/orm/events.pyi index 96741569..119bdb1a 100644 --- a/stubs/sqlalchemy/orm/events.pyi +++ b/stubs/sqlalchemy/orm/events.pyi @@ -26,7 +26,9 @@ class InstanceEvents(event.Events): class _EventsHold(event.RefCollection): class_: Any = ... def __init__(self, class_) -> None: ... + class HoldEvents(object): ... + def remove(self, event_key): ... @classmethod def populate(cls, class_, subject): ... @@ -34,6 +36,7 @@ class _EventsHold(event.RefCollection): class _InstanceEventsHold(_EventsHold): all_holds: Any = ... def resolve(self, class_): ... + class HoldInstanceEvents(_EventsHold.HoldEvents, InstanceEvents): ... dispatch: Any = ... @@ -52,6 +55,7 @@ class MapperEvents(event.Events): class _MapperEventsHold(_EventsHold): all_holds: Any = ... def resolve(self, class_): ... + class HoldMapperEvents(_EventsHold.HoldEvents, MapperEvents): ... dispatch: Any = ... diff --git a/stubs/sqlalchemy/orm/interfaces.pyi b/stubs/sqlalchemy/orm/interfaces.pyi index 22a39432..73ec2ad2 100644 --- a/stubs/sqlalchemy/orm/interfaces.pyi +++ b/stubs/sqlalchemy/orm/interfaces.pyi @@ -2,15 +2,17 @@ from typing import Any, Optional from .. import util from ..sql import operators -from .base import EXT_CONTINUE as EXT_CONTINUE -from .base import EXT_STOP as EXT_STOP -from .base import MANYTOMANY as MANYTOMANY -from .base import MANYTOONE as MANYTOONE -from .base import NOT_EXTENSION as NOT_EXTENSION -from .base import ONETOMANY as ONETOMANY -from .base import InspectionAttr as InspectionAttr -from .base import InspectionAttrInfo as InspectionAttrInfo -from .base import _MappedAttribute as _MappedAttribute +from .base import ( + _MappedAttribute as _MappedAttribute, + EXT_CONTINUE as EXT_CONTINUE, + EXT_STOP as EXT_STOP, + InspectionAttr as InspectionAttr, + InspectionAttrInfo as InspectionAttrInfo, + MANYTOMANY as MANYTOMANY, + MANYTOONE as MANYTOONE, + NOT_EXTENSION as NOT_EXTENSION, + ONETOMANY as ONETOMANY, +) MapperExtension: Any = ... SessionExtension: Any = ... diff --git a/stubs/sqlalchemy/orm/properties.pyi b/stubs/sqlalchemy/orm/properties.pyi index aa77e600..60a0bafa 100644 --- a/stubs/sqlalchemy/orm/properties.pyi +++ b/stubs/sqlalchemy/orm/properties.pyi @@ -35,6 +35,7 @@ class ColumnProperty(StrategizedProperty): _recursive, _resolve_conflict_map, ): ... + class Comparator(util.MemoizedSlots, PropComparator): def _memoized_method___clause_element__(self): ... def operate(self, op, *other, **kwargs): ... diff --git a/stubs/sqlalchemy/orm/query.pyi b/stubs/sqlalchemy/orm/query.pyi index 2f5b7512..0e3bb974 100644 --- a/stubs/sqlalchemy/orm/query.pyi +++ b/stubs/sqlalchemy/orm/query.pyi @@ -1,7 +1,7 @@ from typing import Any, Generic, Iterator, List, Optional, TypeVar, Union from ..sql.elements import Label -from ..sql.selectable import CTE, Alias, ForUpdateArg +from ..sql.selectable import Alias, CTE, ForUpdateArg from . import interfaces from .base import InspectionAttr from .session import Session diff --git a/stubs/sqlalchemy/orm/relationships.pyi b/stubs/sqlalchemy/orm/relationships.pyi index a9778781..0a097dc6 100644 --- a/stubs/sqlalchemy/orm/relationships.pyi +++ b/stubs/sqlalchemy/orm/relationships.pyi @@ -1,12 +1,14 @@ -from typing import Any, Generic, List, Optional, Type, TypeVar, Union, overload +from typing import Any, Generic, List, Optional, overload, Type, TypeVar, Union -from typing_extensions import Literal, final +from typing_extensions import final, Literal -from .interfaces import MANYTOMANY as MANYTOMANY -from .interfaces import MANYTOONE as MANYTOONE -from .interfaces import ONETOMANY as ONETOMANY -from .interfaces import PropComparator as PropComparator -from .interfaces import StrategizedProperty as StrategizedProperty +from .interfaces import ( + MANYTOMANY as MANYTOMANY, + MANYTOONE as MANYTOONE, + ONETOMANY as ONETOMANY, + PropComparator as PropComparator, + StrategizedProperty as StrategizedProperty, +) def remote(expr): ... def foreign(expr): ... @@ -129,6 +131,7 @@ class RelationshipProperty(StrategizedProperty, Generic[_T_co]): info: Optional[Any] = ..., ) -> RelationshipProperty[_T_co]: ... def instrument_class(self, mapper): ... + class Comparator(PropComparator): prop: Any = ... def __init__( diff --git a/stubs/sqlalchemy/orm/session.pyi b/stubs/sqlalchemy/orm/session.pyi index 741a35e5..298672a8 100644 --- a/stubs/sqlalchemy/orm/session.pyi +++ b/stubs/sqlalchemy/orm/session.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Type, TypeVar, Union, overload +from typing import Any, Optional, overload, Type, TypeVar, Union from sqlalchemy import Column from sqlalchemy.orm.query import Query diff --git a/stubs/sqlalchemy/orm/state.pyi b/stubs/sqlalchemy/orm/state.pyi index 67f55091..c0e7b6d6 100644 --- a/stubs/sqlalchemy/orm/state.pyi +++ b/stubs/sqlalchemy/orm/state.pyi @@ -1,14 +1,16 @@ from typing import Any from . import interfaces -from .base import ATTR_WAS_SET as ATTR_WAS_SET -from .base import INIT_OK as INIT_OK -from .base import NEVER_SET as NEVER_SET -from .base import NO_VALUE as NO_VALUE -from .base import PASSIVE_NO_INITIALIZE as PASSIVE_NO_INITIALIZE -from .base import PASSIVE_NO_RESULT as PASSIVE_NO_RESULT -from .base import PASSIVE_OFF as PASSIVE_OFF -from .base import SQL_OK as SQL_OK +from .base import ( + ATTR_WAS_SET as ATTR_WAS_SET, + INIT_OK as INIT_OK, + NEVER_SET as NEVER_SET, + NO_VALUE as NO_VALUE, + PASSIVE_NO_INITIALIZE as PASSIVE_NO_INITIALIZE, + PASSIVE_NO_RESULT as PASSIVE_NO_RESULT, + PASSIVE_OFF as PASSIVE_OFF, + SQL_OK as SQL_OK, +) class InstanceState(interfaces.InspectionAttr): session_id: Any = ... diff --git a/stubs/sqlalchemy/orm/strategies.pyi b/stubs/sqlalchemy/orm/strategies.pyi index 07b978ab..8fe16a5d 100644 --- a/stubs/sqlalchemy/orm/strategies.pyi +++ b/stubs/sqlalchemy/orm/strategies.pyi @@ -117,11 +117,13 @@ class SubqueryLoader(AbstractRelationshipLoader): parentmapper: Optional[Any] = ..., **kwargs ): ... + class _SubqCollections(object): subq: Any = ... def __init__(self, subq) -> None: ... def get(self, key, default): ... def loader(self, state, dict_, row): ... + def create_row_processor( self, context, path, loadopt, mapper, result, adapter, populators ): ... diff --git a/stubs/sqlalchemy/orm/util.pyi b/stubs/sqlalchemy/orm/util.pyi index a2c8d1ec..89ac5ff4 100644 --- a/stubs/sqlalchemy/orm/util.pyi +++ b/stubs/sqlalchemy/orm/util.pyi @@ -1,10 +1,8 @@ from typing import Any, Optional, Text -from ..sql import expression -from ..sql import util as sql_util +from ..sql import expression, util as sql_util from ..sql.selectable import FromClause -from .base import InspectionAttr as InspectionAttr -from .base import object_mapper as object_mapper +from .base import InspectionAttr as InspectionAttr, object_mapper as object_mapper all_cascades: Any = ... diff --git a/stubs/sqlalchemy/schema.pyi b/stubs/sqlalchemy/schema.pyi index c18fcca5..28e88240 100644 --- a/stubs/sqlalchemy/schema.pyi +++ b/stubs/sqlalchemy/schema.pyi @@ -1,42 +1,46 @@ from .sql.base import SchemaVisitor as SchemaVisitor -from .sql.ddl import DDL as DDL -from .sql.ddl import AddConstraint as AddConstraint -from .sql.ddl import CreateColumn as CreateColumn -from .sql.ddl import CreateIndex as CreateIndex -from .sql.ddl import CreateSchema as CreateSchema -from .sql.ddl import CreateSequence as CreateSequence -from .sql.ddl import CreateTable as CreateTable -from .sql.ddl import DDLBase as DDLBase -from .sql.ddl import DDLElement as DDLElement -from .sql.ddl import DropConstraint as DropConstraint -from .sql.ddl import DropIndex as DropIndex -from .sql.ddl import DropSchema as DropSchema -from .sql.ddl import DropSequence as DropSequence -from .sql.ddl import DropTable as DropTable -from .sql.ddl import _CreateDropBase as _CreateDropBase -from .sql.ddl import _DDLCompiles as _DDLCompiles -from .sql.ddl import _DropView as _DropView -from .sql.ddl import sort_tables as sort_tables -from .sql.ddl import sort_tables_and_constraints as sort_tables_and_constraints +from .sql.ddl import ( + _CreateDropBase as _CreateDropBase, + _DDLCompiles as _DDLCompiles, + _DropView as _DropView, + AddConstraint as AddConstraint, + CreateColumn as CreateColumn, + CreateIndex as CreateIndex, + CreateSchema as CreateSchema, + CreateSequence as CreateSequence, + CreateTable as CreateTable, + DDL as DDL, + DDLBase as DDLBase, + DDLElement as DDLElement, + DropConstraint as DropConstraint, + DropIndex as DropIndex, + DropSchema as DropSchema, + DropSequence as DropSequence, + DropTable as DropTable, + sort_tables as sort_tables, + sort_tables_and_constraints as sort_tables_and_constraints, +) from .sql.naming import conv as conv -from .sql.schema import BLANK_SCHEMA as BLANK_SCHEMA -from .sql.schema import CheckConstraint as CheckConstraint -from .sql.schema import Column as Column -from .sql.schema import ColumnCollectionConstraint as ColumnCollectionConstraint -from .sql.schema import ColumnCollectionMixin as ColumnCollectionMixin -from .sql.schema import ColumnDefault as ColumnDefault -from .sql.schema import Constraint as Constraint -from .sql.schema import DefaultClause as DefaultClause -from .sql.schema import DefaultGenerator as DefaultGenerator -from .sql.schema import FetchedValue as FetchedValue -from .sql.schema import ForeignKey as ForeignKey -from .sql.schema import ForeignKeyConstraint as ForeignKeyConstraint -from .sql.schema import Index as Index -from .sql.schema import MetaData as MetaData -from .sql.schema import PassiveDefault as PassiveDefault -from .sql.schema import PrimaryKeyConstraint as PrimaryKeyConstraint -from .sql.schema import SchemaItem as SchemaItem -from .sql.schema import Sequence as Sequence -from .sql.schema import Table as Table -from .sql.schema import ThreadLocalMetaData as ThreadLocalMetaData -from .sql.schema import UniqueConstraint as UniqueConstraint +from .sql.schema import ( + BLANK_SCHEMA as BLANK_SCHEMA, + CheckConstraint as CheckConstraint, + Column as Column, + ColumnCollectionConstraint as ColumnCollectionConstraint, + ColumnCollectionMixin as ColumnCollectionMixin, + ColumnDefault as ColumnDefault, + Constraint as Constraint, + DefaultClause as DefaultClause, + DefaultGenerator as DefaultGenerator, + FetchedValue as FetchedValue, + ForeignKey as ForeignKey, + ForeignKeyConstraint as ForeignKeyConstraint, + Index as Index, + MetaData as MetaData, + PassiveDefault as PassiveDefault, + PrimaryKeyConstraint as PrimaryKeyConstraint, + SchemaItem as SchemaItem, + Sequence as Sequence, + Table as Table, + ThreadLocalMetaData as ThreadLocalMetaData, + UniqueConstraint as UniqueConstraint, +) diff --git a/stubs/sqlalchemy/sql/__init__.pyi b/stubs/sqlalchemy/sql/__init__.pyi index b5cd1bdd..86a41cc6 100644 --- a/stubs/sqlalchemy/sql/__init__.pyi +++ b/stubs/sqlalchemy/sql/__init__.pyi @@ -1,65 +1,67 @@ -from .expression import Alias as Alias -from .expression import ClauseElement as ClauseElement -from .expression import ColumnCollection as ColumnCollection -from .expression import ColumnElement as ColumnElement -from .expression import CompoundSelect as CompoundSelect -from .expression import Delete as Delete -from .expression import False_ as False_ -from .expression import FromClause as FromClause -from .expression import Insert as Insert -from .expression import Join as Join -from .expression import Select as Select -from .expression import Selectable as Selectable -from .expression import TableClause as TableClause -from .expression import TableSample as TableSample -from .expression import True_ as True_ -from .expression import Update as Update -from .expression import alias as alias -from .expression import all_ as all_ -from .expression import and_ as and_ -from .expression import any_ as any_ -from .expression import asc as asc -from .expression import between as between -from .expression import bindparam as bindparam -from .expression import case as case -from .expression import cast as cast -from .expression import collate as collate -from .expression import column as column -from .expression import delete as delete -from .expression import desc as desc -from .expression import distinct as distinct -from .expression import except_ as except_ -from .expression import except_all as except_all -from .expression import exists as exists -from .expression import extract as extract -from .expression import false as false -from .expression import func as func -from .expression import funcfilter as funcfilter -from .expression import insert as insert -from .expression import intersect as intersect -from .expression import intersect_all as intersect_all -from .expression import join as join -from .expression import label as label -from .expression import lateral as lateral -from .expression import literal as literal -from .expression import literal_column as literal_column -from .expression import modifier as modifier -from .expression import not_ as not_ -from .expression import null as null -from .expression import or_ as or_ -from .expression import outerjoin as outerjoin -from .expression import outparam as outparam -from .expression import over as over -from .expression import select as select -from .expression import subquery as subquery -from .expression import table as table -from .expression import tablesample as tablesample -from .expression import text as text -from .expression import true as true -from .expression import tuple_ as tuple_ -from .expression import type_coerce as type_coerce -from .expression import union as union -from .expression import union_all as union_all -from .expression import update as update -from .expression import within_group as within_group +from .expression import ( + Alias as Alias, + alias as alias, + all_ as all_, + and_ as and_, + any_ as any_, + asc as asc, + between as between, + bindparam as bindparam, + case as case, + cast as cast, + ClauseElement as ClauseElement, + collate as collate, + column as column, + ColumnCollection as ColumnCollection, + ColumnElement as ColumnElement, + CompoundSelect as CompoundSelect, + Delete as Delete, + delete as delete, + desc as desc, + distinct as distinct, + except_ as except_, + except_all as except_all, + exists as exists, + extract as extract, + false as false, + False_ as False_, + FromClause as FromClause, + func as func, + funcfilter as funcfilter, + Insert as Insert, + insert as insert, + intersect as intersect, + intersect_all as intersect_all, + Join as Join, + join as join, + label as label, + lateral as lateral, + literal as literal, + literal_column as literal_column, + modifier as modifier, + not_ as not_, + null as null, + or_ as or_, + outerjoin as outerjoin, + outparam as outparam, + over as over, + Select as Select, + select as select, + Selectable as Selectable, + subquery as subquery, + table as table, + TableClause as TableClause, + TableSample as TableSample, + tablesample as tablesample, + text as text, + true as true, + True_ as True_, + tuple_ as tuple_, + type_coerce as type_coerce, + union as union, + union_all as union_all, + Update as Update, + update as update, + within_group as within_group, +) from .visitors import ClauseVisitor as ClauseVisitor diff --git a/stubs/sqlalchemy/sql/ddl.pyi b/stubs/sqlalchemy/sql/ddl.pyi index 5d8d9bef..186c3d3c 100644 --- a/stubs/sqlalchemy/sql/ddl.pyi +++ b/stubs/sqlalchemy/sql/ddl.pyi @@ -15,11 +15,9 @@ from typing import ( from typing_extensions import Protocol from ..engine import Connectable, Connection, Dialect, Engine, ResultProxy -from .base import Executable as Executable -from .base import SchemaVisitor as SchemaVisitor +from .base import Executable as Executable, SchemaVisitor as SchemaVisitor from .compiler import IdentifierPreparer -from .elements import ClauseElement as ClauseElement -from .elements import ColumnElement +from .elements import ClauseElement as ClauseElement, ColumnElement from .schema import ForeignKey, ForeignKeyConstraint, MetaData, SchemaItem, Table from .type_api import TypeEngine diff --git a/stubs/sqlalchemy/sql/dml.pyi b/stubs/sqlalchemy/sql/dml.pyi index dde515ec..a8fb82a1 100644 --- a/stubs/sqlalchemy/sql/dml.pyi +++ b/stubs/sqlalchemy/sql/dml.pyi @@ -1,13 +1,14 @@ from typing import Any, Iterable, Optional, Tuple, TypeVar, Union -from .base import DialectKWArgs as DialectKWArgs -from .base import Executable as Executable -from .elements import ClauseElement as ClauseElement -from .elements import ColumnElement, TextClause +from .base import DialectKWArgs as DialectKWArgs, Executable as Executable +from .elements import ClauseElement as ClauseElement, ColumnElement, TextClause from .schema import Column, Table -from .selectable import HasCTE as HasCTE -from .selectable import HasPrefixes as HasPrefixes -from .selectable import Selectable, TableClause +from .selectable import ( + HasCTE as HasCTE, + HasPrefixes as HasPrefixes, + Selectable, + TableClause, +) from .visitors import Visitable _UB = TypeVar("_UB", bound=UpdateBase) diff --git a/stubs/sqlalchemy/sql/elements.pyi b/stubs/sqlalchemy/sql/elements.pyi index f2ee991d..7d4f9a4f 100644 --- a/stubs/sqlalchemy/sql/elements.pyi +++ b/stubs/sqlalchemy/sql/elements.pyi @@ -8,11 +8,14 @@ from typing import ( List, Mapping, Optional, + overload, Set, Text, + Tuple as _TupleType, + Type, + TypeVar, + Union, ) -from typing import Tuple as _TupleType -from typing import Type, TypeVar, Union, overload from typing_extensions import Protocol @@ -20,8 +23,7 @@ from .. import util from ..engine.base import Connection, Engine from . import operators from .annotation import Annotated as Annotated -from .base import Executable as Executable -from .base import Immutable as Immutable +from .base import Executable as Executable, Immutable as Immutable from .functions import FunctionElement from .schema import ForeignKey from .selectable import TableClause, TextAsFrom diff --git a/stubs/sqlalchemy/sql/expression.pyi b/stubs/sqlalchemy/sql/expression.pyi index 8bd5e12a..aca59fd4 100644 --- a/stubs/sqlalchemy/sql/expression.pyi +++ b/stubs/sqlalchemy/sql/expression.pyi @@ -1,66 +1,72 @@ -from .base import ColumnCollection as ColumnCollection -from .base import Executable as Executable -from .base import Generative as Generative -from .dml import Delete as Delete -from .dml import Insert as Insert -from .dml import Update as Update -from .elements import BinaryExpression as BinaryExpression -from .elements import BindParameter as BindParameter -from .elements import BooleanClauseList as BooleanClauseList -from .elements import Case as Case -from .elements import Cast as Cast -from .elements import ClauseElement as ClauseElement -from .elements import ClauseList as ClauseList -from .elements import CollectionAggregate as CollectionAggregate -from .elements import ColumnClause as ColumnClause -from .elements import ColumnElement as ColumnElement -from .elements import Extract as Extract -from .elements import False_ as False_ -from .elements import FunctionFilter as FunctionFilter -from .elements import Grouping as Grouping -from .elements import Label as Label -from .elements import Null as Null -from .elements import Over as Over -from .elements import TextClause as TextClause -from .elements import True_ as True_ -from .elements import Tuple as Tuple -from .elements import TypeClause as TypeClause -from .elements import TypeCoerce as TypeCoerce -from .elements import UnaryExpression as UnaryExpression -from .elements import WithinGroup as WithinGroup -from .elements import between as between -from .elements import collate as collate -from .elements import literal as literal -from .elements import literal_column as literal_column -from .elements import not_ as not_ -from .elements import outparam as outparam -from .functions import Function as Function -from .functions import FunctionElement as FunctionElement -from .functions import func as func -from .functions import modifier as modifier -from .selectable import CTE as CTE -from .selectable import Alias as Alias -from .selectable import CompoundSelect as CompoundSelect -from .selectable import Exists as Exists -from .selectable import FromClause as FromClause -from .selectable import FromGrouping as FromGrouping -from .selectable import GenerativeSelect as GenerativeSelect -from .selectable import HasCTE as HasCTE -from .selectable import HasPrefixes as HasPrefixes -from .selectable import HasSuffixes as HasSuffixes -from .selectable import Join as Join -from .selectable import Lateral as Lateral -from .selectable import ScalarSelect as ScalarSelect -from .selectable import Select as Select -from .selectable import Selectable as Selectable -from .selectable import SelectBase as SelectBase -from .selectable import TableClause as TableClause -from .selectable import TableSample as TableSample -from .selectable import TextAsFrom as TextAsFrom -from .selectable import alias as alias -from .selectable import lateral as lateral -from .selectable import subquery as subquery -from .selectable import tablesample as tablesample +from .base import ( + ColumnCollection as ColumnCollection, + Executable as Executable, + Generative as Generative, +) +from .dml import Delete as Delete, Insert as Insert, Update as Update +from .elements import ( + between as between, + BinaryExpression as BinaryExpression, + BindParameter as BindParameter, + BooleanClauseList as BooleanClauseList, + Case as Case, + Cast as Cast, + ClauseElement as ClauseElement, + ClauseList as ClauseList, + collate as collate, + CollectionAggregate as CollectionAggregate, + ColumnClause as ColumnClause, + ColumnElement as ColumnElement, + Extract as Extract, + False_ as False_, + FunctionFilter as FunctionFilter, + Grouping as Grouping, + Label as Label, + literal as literal, + literal_column as literal_column, + not_ as not_, + Null as Null, + outparam as outparam, + Over as Over, + TextClause as TextClause, + True_ as True_, + Tuple as Tuple, + TypeClause as TypeClause, + TypeCoerce as TypeCoerce, + UnaryExpression as UnaryExpression, + WithinGroup as WithinGroup, +) +from .functions import ( + func as func, + Function as Function, + FunctionElement as FunctionElement, + modifier as modifier, +) +from .selectable import ( + Alias as Alias, + alias as alias, + CompoundSelect as CompoundSelect, + CTE as CTE, + Exists as Exists, + FromClause as FromClause, + FromGrouping as FromGrouping, + GenerativeSelect as GenerativeSelect, + HasCTE as HasCTE, + HasPrefixes as HasPrefixes, + HasSuffixes as HasSuffixes, + Join as Join, + Lateral as Lateral, + lateral as lateral, + ScalarSelect as ScalarSelect, + Select as Select, + Selectable as Selectable, + SelectBase as SelectBase, + subquery as subquery, + TableClause as TableClause, + TableSample as TableSample, + tablesample as tablesample, + TextAsFrom as TextAsFrom, +) all_ = CollectionAggregate._create_all any_ = CollectionAggregate._create_any diff --git a/stubs/sqlalchemy/sql/functions.pyi b/stubs/sqlalchemy/sql/functions.pyi index 2cabac6d..2f2da464 100644 --- a/stubs/sqlalchemy/sql/functions.pyi +++ b/stubs/sqlalchemy/sql/functions.pyi @@ -5,27 +5,29 @@ from typing import ( Iterable, List, Optional, + overload, Text, Tuple, Type, TypeVar, Union, - overload, ) from ..engine.base import Connection, Engine from ..engine.result import ResultProxy -from . import sqltypes -from . import util as sqlutil -from .base import ColumnCollection -from .base import Executable as Executable -from .elements import AsBoolean, ClauseList -from .elements import ColumnElement as ColumnElement -from .elements import FunctionFilter, Grouping, Over, WithinGroup +from . import sqltypes, util as sqlutil +from .base import ColumnCollection, Executable as Executable +from .elements import ( + AsBoolean, + ClauseList, + ColumnElement as ColumnElement, + FunctionFilter, + Grouping, + Over, + WithinGroup, +) from .schema import Sequence -from .selectable import Alias -from .selectable import FromClause as FromClause -from .selectable import Select +from .selectable import Alias, FromClause as FromClause, Select from .type_api import TypeEngine from .visitors import VisitableType as VisitableType diff --git a/stubs/sqlalchemy/sql/operators.pyi b/stubs/sqlalchemy/sql/operators.pyi index 82cf0d48..8b38ab7c 100644 --- a/stubs/sqlalchemy/sql/operators.pyi +++ b/stubs/sqlalchemy/sql/operators.pyi @@ -1,7 +1,6 @@ from typing import Any, Iterable, Optional, Text, Union -from .elements import BindParameter as BindParameter -from .elements import UnaryExpression +from .elements import BindParameter as BindParameter, UnaryExpression from .selectable import Select as Select class Operators(object): diff --git a/stubs/sqlalchemy/sql/schema.pyi b/stubs/sqlalchemy/sql/schema.pyi index db7e6f22..b159c573 100644 --- a/stubs/sqlalchemy/sql/schema.pyi +++ b/stubs/sqlalchemy/sql/schema.pyi @@ -1,20 +1,35 @@ import threading -from typing import Any, Callable, Generic, Iterable, Iterator, List, Mapping, Optional -from typing import Sequence as SequenceType -from typing import Set, Tuple, Type, TypeVar, Union, overload - -from typing_extensions import Literal, final +from typing import ( + Any, + Callable, + Generic, + Iterable, + Iterator, + List, + Mapping, + Optional, + overload, + Sequence as SequenceType, + Set, + Tuple, + Type, + TypeVar, + Union, +) + +from typing_extensions import final, Literal from .. import util from ..engine import Connectable, Connection, Engine from ..engine.url import URL from . import functions, visitors -from .base import ColumnCollection -from .base import DialectKWArgs as DialectKWArgs -from .base import SchemaEventTarget as SchemaEventTarget +from .base import ( + ColumnCollection, + DialectKWArgs as DialectKWArgs, + SchemaEventTarget as SchemaEventTarget, +) from .compiler import DDLCompiler -from .elements import ColumnClause as ColumnClause -from .elements import ColumnElement, TextClause +from .elements import ColumnClause as ColumnClause, ColumnElement, TextClause from .expression import FunctionElement from .selectable import TableClause as TableClause from .type_api import TypeEngine diff --git a/stubs/sqlalchemy/sql/selectable.pyi b/stubs/sqlalchemy/sql/selectable.pyi index 67be9c9b..e06a90e6 100644 --- a/stubs/sqlalchemy/sql/selectable.pyi +++ b/stubs/sqlalchemy/sql/selectable.pyi @@ -15,18 +15,24 @@ from typing import ( from .. import util from ..engine import Connection, Engine from .annotation import Annotated as Annotated -from .base import ColumnSet -from .base import Executable as Executable -from .base import Generative as Generative -from .base import Immutable as Immutable -from .base import ImmutableColumnCollection +from .base import ( + ColumnSet, + Executable as Executable, + Generative as Generative, + Immutable as Immutable, + ImmutableColumnCollection, +) from .dml import Delete, Insert, Update -from .elements import BindParameter -from .elements import ClauseElement as ClauseElement -from .elements import ColumnClause, ColumnElement -from .elements import Grouping as Grouping -from .elements import Label, TextClause -from .elements import UnaryExpression as UnaryExpression +from .elements import ( + BindParameter, + ClauseElement as ClauseElement, + ColumnClause, + ColumnElement, + Grouping as Grouping, + Label, + TextClause, + UnaryExpression as UnaryExpression, +) from .functions import Function from .schema import ForeignKey, Table from .type_api import TypeEngine diff --git a/stubs/sqlalchemy/sql/sqltypes.pyi b/stubs/sqlalchemy/sql/sqltypes.pyi index 597c3986..2dbb617f 100644 --- a/stubs/sqlalchemy/sql/sqltypes.pyi +++ b/stubs/sqlalchemy/sql/sqltypes.pyi @@ -1,9 +1,20 @@ import decimal import sys from datetime import date, datetime, time, timedelta -from typing import IO, Any, Callable, Dict, List, Optional -from typing import Text as typing_Text -from typing import Tuple, Type, TypeVar, Union, overload +from typing import ( + Any, + Callable, + Dict, + IO, + List, + Optional, + overload, + Text as typing_Text, + Tuple, + Type, + TypeVar, + Union, +) from typing_extensions import Protocol @@ -11,10 +22,12 @@ from .. import util from ..engine import Connectable, Connection, Dialect, Engine from .base import SchemaEventTarget as SchemaEventTarget from .schema import MetaData -from .type_api import Emulated -from .type_api import NativeForEmulated as NativeForEmulated -from .type_api import TypeDecorator as TypeDecorator -from .type_api import TypeEngine as TypeEngine +from .type_api import ( + Emulated, + NativeForEmulated as NativeForEmulated, + TypeDecorator as TypeDecorator, + TypeEngine as TypeEngine, +) _T = TypeVar("_T") @@ -381,11 +394,13 @@ class JSON(Indexable, TypeEngine[_JSONT]): NULL: util.symbol = ... none_as_null: bool = ... def __init__(self, none_as_null: bool = ...) -> None: ... + class JSONElementType(TypeEngine[Union[int, str]]): def string_bind_processor(self, dialect): ... def string_literal_processor(self, dialect): ... def bind_processor(self, dialect): ... def literal_processor(self, dialect): ... + class JSONIndexType(JSONElementType): ... class JSONPathType(JSONElementType): ... comparator_factory: Type[Any] = ... diff --git a/stubs/sqlalchemy/sql/type_api.pyi b/stubs/sqlalchemy/sql/type_api.pyi index 09f52ebf..68e90a46 100644 --- a/stubs/sqlalchemy/sql/type_api.pyi +++ b/stubs/sqlalchemy/sql/type_api.pyi @@ -1,6 +1,17 @@ -from typing import Any, Callable, ClassVar, Generic, Mapping, Optional -from typing import Text as typing_Text -from typing import Tuple, Type, TypeVar, Union, overload +from typing import ( + Any, + Callable, + ClassVar, + Generic, + Mapping, + Optional, + overload, + Text as typing_Text, + Tuple, + Type, + TypeVar, + Union, +) from .. import util from ..engine.interfaces import Dialect @@ -8,8 +19,7 @@ from . import operators from .base import SchemaEventTarget as SchemaEventTarget from .elements import BindParameter, ColumnElement from .sqltypes import Boolean, Indexable, Integer, MatchType, NullType, String -from .visitors import Visitable as Visitable -from .visitors import VisitableType as VisitableType +from .visitors import Visitable as Visitable, VisitableType as VisitableType _T = TypeVar("_T") _T_co = TypeVar("_T_co", covariant=True) @@ -71,6 +81,7 @@ _UDT = TypeVar("_UDT", bound=UserDefinedType) class UserDefinedType(TypeEngine[_T], metaclass=VisitableCheckKWArg): __visit_name__: str = ... ensure_kwarg: str = ... + class Comparator(TypeEngine.Comparator): ... comparator_factory: Type[Any] = ... def coerce_compared_value(self: _UDT, op: Any, value: Any) -> _UDT: ... @@ -94,6 +105,7 @@ class TypeDecorator(SchemaEventTarget, TypeEngine[_T]): ) # impl is Type[TypeEngine[Any]] on the class, but TypeEngine[Any] on instances def __init__(self, *args: Any, **kwargs: Any) -> None: ... coerce_to_is_types: Tuple[Type[Any], ...] = ... + class Comparator(TypeEngine.Comparator): def operate(self, op, *other, **kwargs): ... def reverse_operate(self, op, other, **kwargs): ... diff --git a/stubs/sqlalchemy/types.pyi b/stubs/sqlalchemy/types.pyi index 4d6b0f6a..9097fbdb 100644 --- a/stubs/sqlalchemy/types.pyi +++ b/stubs/sqlalchemy/types.pyi @@ -1,52 +1,56 @@ -from .sql.sqltypes import ARRAY as ARRAY -from .sql.sqltypes import BIGINT as BIGINT -from .sql.sqltypes import BINARY as BINARY -from .sql.sqltypes import BLOB as BLOB -from .sql.sqltypes import BOOLEAN as BOOLEAN -from .sql.sqltypes import CHAR as CHAR -from .sql.sqltypes import CLOB as CLOB -from .sql.sqltypes import DATE as DATE -from .sql.sqltypes import DATETIME as DATETIME -from .sql.sqltypes import DECIMAL as DECIMAL -from .sql.sqltypes import FLOAT as FLOAT -from .sql.sqltypes import INT as INT -from .sql.sqltypes import INTEGER as INTEGER -from .sql.sqltypes import JSON as JSON -from .sql.sqltypes import NCHAR as NCHAR -from .sql.sqltypes import NUMERIC as NUMERIC -from .sql.sqltypes import NVARCHAR as NVARCHAR -from .sql.sqltypes import REAL as REAL -from .sql.sqltypes import SMALLINT as SMALLINT -from .sql.sqltypes import TEXT as TEXT -from .sql.sqltypes import TIME as TIME -from .sql.sqltypes import TIMESTAMP as TIMESTAMP -from .sql.sqltypes import VARBINARY as VARBINARY -from .sql.sqltypes import VARCHAR as VARCHAR -from .sql.sqltypes import BigInteger as BigInteger -from .sql.sqltypes import Binary as Binary -from .sql.sqltypes import Boolean as Boolean -from .sql.sqltypes import Concatenable as Concatenable -from .sql.sqltypes import Date as Date -from .sql.sqltypes import DateTime as DateTime -from .sql.sqltypes import Enum as Enum -from .sql.sqltypes import Float as Float -from .sql.sqltypes import Indexable as Indexable -from .sql.sqltypes import Integer as Integer -from .sql.sqltypes import Interval as Interval -from .sql.sqltypes import LargeBinary as LargeBinary -from .sql.sqltypes import MatchType as MatchType -from .sql.sqltypes import Numeric as Numeric -from .sql.sqltypes import PickleType as PickleType -from .sql.sqltypes import SmallInteger as SmallInteger -from .sql.sqltypes import String as String -from .sql.sqltypes import Text as Text -from .sql.sqltypes import Time as Time -from .sql.sqltypes import Unicode as Unicode -from .sql.sqltypes import UnicodeText as UnicodeText -from .sql.sqltypes import _Binary as _Binary -from .sql.type_api import TypeDecorator as TypeDecorator -from .sql.type_api import TypeEngine as TypeEngine -from .sql.type_api import UserDefinedType as UserDefinedType -from .sql.type_api import Variant as Variant -from .sql.type_api import adapt_type as adapt_type -from .sql.type_api import to_instance as to_instance +from .sql.sqltypes import ( + _Binary as _Binary, + ARRAY as ARRAY, + BIGINT as BIGINT, + BigInteger as BigInteger, + BINARY as BINARY, + Binary as Binary, + BLOB as BLOB, + BOOLEAN as BOOLEAN, + Boolean as Boolean, + CHAR as CHAR, + CLOB as CLOB, + Concatenable as Concatenable, + DATE as DATE, + Date as Date, + DATETIME as DATETIME, + DateTime as DateTime, + DECIMAL as DECIMAL, + Enum as Enum, + FLOAT as FLOAT, + Float as Float, + Indexable as Indexable, + INT as INT, + INTEGER as INTEGER, + Integer as Integer, + Interval as Interval, + JSON as JSON, + LargeBinary as LargeBinary, + MatchType as MatchType, + NCHAR as NCHAR, + NUMERIC as NUMERIC, + Numeric as Numeric, + NVARCHAR as NVARCHAR, + PickleType as PickleType, + REAL as REAL, + SMALLINT as SMALLINT, + SmallInteger as SmallInteger, + String as String, + TEXT as TEXT, + Text as Text, + TIME as TIME, + Time as Time, + TIMESTAMP as TIMESTAMP, + Unicode as Unicode, + UnicodeText as UnicodeText, + VARBINARY as VARBINARY, + VARCHAR as VARCHAR, +) +from .sql.type_api import ( + adapt_type as adapt_type, + to_instance as to_instance, + TypeDecorator as TypeDecorator, + TypeEngine as TypeEngine, + UserDefinedType as UserDefinedType, + Variant as Variant, +) diff --git a/stubs/sqlalchemy/util/__init__.pyi b/stubs/sqlalchemy/util/__init__.pyi index ace75754..7ca4d6e1 100644 --- a/stubs/sqlalchemy/util/__init__.pyi +++ b/stubs/sqlalchemy/util/__init__.pyi @@ -1,128 +1,134 @@ -from ._collections import EMPTY_SET as EMPTY_SET -from ._collections import IdentitySet as IdentitySet -from ._collections import ImmutableContainer as ImmutableContainer -from ._collections import ImmutableProperties as ImmutableProperties -from ._collections import KeyedTuple as KeyedTuple -from ._collections import LRUCache as LRUCache -from ._collections import OrderedDict as OrderedDict -from ._collections import OrderedIdentitySet as OrderedIdentitySet -from ._collections import OrderedProperties as OrderedProperties -from ._collections import OrderedSet as OrderedSet -from ._collections import PopulateDict as PopulateDict -from ._collections import Properties as Properties -from ._collections import ScopedRegistry as ScopedRegistry -from ._collections import ThreadLocalRegistry as ThreadLocalRegistry -from ._collections import UniqueAppender as UniqueAppender -from ._collections import WeakSequence as WeakSequence -from ._collections import coerce_generator_arg as coerce_generator_arg -from ._collections import column_dict as column_dict -from ._collections import column_set as column_set -from ._collections import flatten_iterator as flatten_iterator -from ._collections import has_intersection as has_intersection -from ._collections import immutabledict as immutabledict -from ._collections import lightweight_named_tuple as lightweight_named_tuple -from ._collections import ordered_column_set as ordered_column_set -from ._collections import populate_column_dict as populate_column_dict -from ._collections import to_column_set as to_column_set -from ._collections import to_list as to_list -from ._collections import to_set as to_set -from ._collections import unique_list as unique_list -from ._collections import update_copy as update_copy -from .compat import StringIO as StringIO -from .compat import b as b -from .compat import b64decode as b64decode -from .compat import b64encode as b64encode -from .compat import binary_type as binary_type -from .compat import byte_buffer as byte_buffer -from .compat import callable as callable -from .compat import cmp as cmp -from .compat import cpython as cpython -from .compat import dottedgetter as dottedgetter -from .compat import inspect_getargspec as inspect_getargspec -from .compat import int_types as int_types -from .compat import iterbytes as iterbytes -from .compat import itertools_filter as itertools_filter -from .compat import itertools_filterfalse as itertools_filterfalse -from .compat import jython as jython -from .compat import namedtuple as namedtuple -from .compat import nested as nested -from .compat import next as next -from .compat import parse_qsl as parse_qsl -from .compat import pickle as pickle -from .compat import print_ as print_ -from .compat import py2k as py2k -from .compat import py3k as py3k -from .compat import py33 as py33 -from .compat import py36 as py36 -from .compat import pypy as pypy -from .compat import quote_plus as quote_plus -from .compat import raise_from_cause as raise_from_cause -from .compat import reduce as reduce -from .compat import reraise as reraise -from .compat import safe_kwarg as safe_kwarg -from .compat import string_types as string_types -from .compat import text_type as text_type -from .compat import threading as threading -from .compat import u as u -from .compat import ue as ue -from .compat import unquote as unquote -from .compat import unquote_plus as unquote_plus -from .compat import win32 as win32 -from .compat import with_metaclass as with_metaclass -from .compat import zip_longest as zip_longest -from .deprecations import deprecated as deprecated -from .deprecations import inject_docstring_text as inject_docstring_text -from .deprecations import pending_deprecation as pending_deprecation -from .deprecations import warn_deprecated as warn_deprecated -from .deprecations import warn_pending_deprecation as warn_pending_deprecation -from .langhelpers import EnsureKWArgType as EnsureKWArgType -from .langhelpers import MemoizedSlots as MemoizedSlots -from .langhelpers import NoneType as NoneType -from .langhelpers import PluginLoader as PluginLoader -from .langhelpers import as_interface as as_interface -from .langhelpers import asbool as asbool -from .langhelpers import asint as asint -from .langhelpers import assert_arg_type as assert_arg_type -from .langhelpers import attrsetter as attrsetter -from .langhelpers import bool_or_str as bool_or_str -from .langhelpers import chop_traceback as chop_traceback -from .langhelpers import class_hierarchy as class_hierarchy -from .langhelpers import classproperty as classproperty -from .langhelpers import coerce_kw_type as coerce_kw_type -from .langhelpers import constructor_copy as constructor_copy -from .langhelpers import counter as counter -from .langhelpers import decode_slice as decode_slice -from .langhelpers import decorator as decorator -from .langhelpers import dependencies as dependencies -from .langhelpers import dictlike_iteritems as dictlike_iteritems -from .langhelpers import duck_type_collection as duck_type_collection -from .langhelpers import ellipses_string as ellipses_string -from .langhelpers import format_argspec_init as format_argspec_init -from .langhelpers import format_argspec_plus as format_argspec_plus -from .langhelpers import generic_repr as generic_repr -from .langhelpers import get_callable_argspec as get_callable_argspec -from .langhelpers import get_cls_kwargs as get_cls_kwargs -from .langhelpers import get_func_kwargs as get_func_kwargs -from .langhelpers import getargspec_init as getargspec_init +from ._collections import ( + coerce_generator_arg as coerce_generator_arg, + column_dict as column_dict, + column_set as column_set, + EMPTY_SET as EMPTY_SET, + flatten_iterator as flatten_iterator, + has_intersection as has_intersection, + IdentitySet as IdentitySet, + ImmutableContainer as ImmutableContainer, + immutabledict as immutabledict, + ImmutableProperties as ImmutableProperties, + KeyedTuple as KeyedTuple, + lightweight_named_tuple as lightweight_named_tuple, + LRUCache as LRUCache, + ordered_column_set as ordered_column_set, + OrderedDict as OrderedDict, + OrderedIdentitySet as OrderedIdentitySet, + OrderedProperties as OrderedProperties, + OrderedSet as OrderedSet, + populate_column_dict as populate_column_dict, + PopulateDict as PopulateDict, + Properties as Properties, + ScopedRegistry as ScopedRegistry, + ThreadLocalRegistry as ThreadLocalRegistry, + to_column_set as to_column_set, + to_list as to_list, + to_set as to_set, + unique_list as unique_list, + UniqueAppender as UniqueAppender, + update_copy as update_copy, + WeakSequence as WeakSequence, +) +from .compat import ( + b as b, + b64decode as b64decode, + b64encode as b64encode, + binary_type as binary_type, + byte_buffer as byte_buffer, + callable as callable, + cmp as cmp, + cpython as cpython, + dottedgetter as dottedgetter, + inspect_getargspec as inspect_getargspec, + int_types as int_types, + iterbytes as iterbytes, + itertools_filter as itertools_filter, + itertools_filterfalse as itertools_filterfalse, + jython as jython, + namedtuple as namedtuple, + nested as nested, + next as next, + parse_qsl as parse_qsl, + pickle as pickle, + print_ as print_, + py2k as py2k, + py33 as py33, + py36 as py36, + py3k as py3k, + pypy as pypy, + quote_plus as quote_plus, + raise_from_cause as raise_from_cause, + reduce as reduce, + reraise as reraise, + safe_kwarg as safe_kwarg, + string_types as string_types, + StringIO as StringIO, + text_type as text_type, + threading as threading, + u as u, + ue as ue, + unquote as unquote, + unquote_plus as unquote_plus, + win32 as win32, + with_metaclass as with_metaclass, + zip_longest as zip_longest, +) +from .deprecations import ( + deprecated as deprecated, + inject_docstring_text as inject_docstring_text, + pending_deprecation as pending_deprecation, + warn_deprecated as warn_deprecated, + warn_pending_deprecation as warn_pending_deprecation, +) from .langhelpers import ( + as_interface as as_interface, + asbool as asbool, + asint as asint, + assert_arg_type as assert_arg_type, + attrsetter as attrsetter, + bool_or_str as bool_or_str, + chop_traceback as chop_traceback, + class_hierarchy as class_hierarchy, + classproperty as classproperty, + coerce_kw_type as coerce_kw_type, + constructor_copy as constructor_copy, + counter as counter, + decode_slice as decode_slice, + decorator as decorator, + dependencies as dependencies, + dictlike_iteritems as dictlike_iteritems, + duck_type_collection as duck_type_collection, + ellipses_string as ellipses_string, + EnsureKWArgType as EnsureKWArgType, + format_argspec_init as format_argspec_init, + format_argspec_plus as format_argspec_plus, + generic_repr as generic_repr, + get_callable_argspec as get_callable_argspec, + get_cls_kwargs as get_cls_kwargs, + get_func_kwargs as get_func_kwargs, + getargspec_init as getargspec_init, group_expirable_memoized_property as group_expirable_memoized_property, + hybridmethod as hybridmethod, + hybridproperty as hybridproperty, + iterate_attributes as iterate_attributes, + map_bits as map_bits, + md5_hex as md5_hex, + memoized_instancemethod as memoized_instancemethod, + memoized_property as memoized_property, + MemoizedSlots as MemoizedSlots, + methods_equivalent as methods_equivalent, + monkeypatch_proxied_specials as monkeypatch_proxied_specials, + NoneType as NoneType, + only_once as only_once, + PluginLoader as PluginLoader, + portable_instancemethod as portable_instancemethod, + safe_reraise as safe_reraise, + set_creation_order as set_creation_order, + symbol as symbol, + unbound_method_to_callable as unbound_method_to_callable, + warn as warn, + warn_exception as warn_exception, + warn_limited as warn_limited, + wrap_callable as wrap_callable, ) -from .langhelpers import hybridmethod as hybridmethod -from .langhelpers import hybridproperty as hybridproperty -from .langhelpers import iterate_attributes as iterate_attributes -from .langhelpers import map_bits as map_bits -from .langhelpers import md5_hex as md5_hex -from .langhelpers import memoized_instancemethod as memoized_instancemethod -from .langhelpers import memoized_property as memoized_property -from .langhelpers import methods_equivalent as methods_equivalent -from .langhelpers import monkeypatch_proxied_specials as monkeypatch_proxied_specials -from .langhelpers import only_once as only_once -from .langhelpers import portable_instancemethod as portable_instancemethod -from .langhelpers import safe_reraise as safe_reraise -from .langhelpers import set_creation_order as set_creation_order -from .langhelpers import symbol as symbol -from .langhelpers import unbound_method_to_callable as unbound_method_to_callable -from .langhelpers import warn as warn -from .langhelpers import warn_exception as warn_exception -from .langhelpers import warn_limited as warn_limited -from .langhelpers import wrap_callable as wrap_callable diff --git a/stubs/sqlalchemy/util/_collections.pyi b/stubs/sqlalchemy/util/_collections.pyi index 5d0c4bea..9d7d4357 100644 --- a/stubs/sqlalchemy/util/_collections.pyi +++ b/stubs/sqlalchemy/util/_collections.pyi @@ -11,12 +11,12 @@ from typing import ( List, Mapping, Optional, + overload, Set, Tuple, Type, TypeVar, Union, - overload, ) _T = TypeVar("_T") @@ -109,6 +109,7 @@ class OrderedDict(Dict[_KT, _VT]): def sort( self, *, key: Optional[Callable[[_VT], Any]] = ..., reverse: bool = ... ) -> None: ... + @overload def update(self, ____sequence: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... @overload @@ -130,6 +131,7 @@ class OrderedDict(Dict[_KT, _VT]): def itervalues(self) -> Iterator[_VT]: ... def iterkeys(self) -> Iterator[_KT]: ... def iteritems(self) -> Iterator[Tuple[_KT, _VT]]: ... + def __setitem__(self, key: _KT, object: _VT) -> None: ... def __delitem__(self, key: _KT) -> None: ... @overload diff --git a/stubs/sqlalchemy/util/compat.pyi b/stubs/sqlalchemy/util/compat.pyi index de599f11..17052583 100644 --- a/stubs/sqlalchemy/util/compat.pyi +++ b/stubs/sqlalchemy/util/compat.pyi @@ -3,8 +3,7 @@ import sys import threading as threading from collections import namedtuple as namedtuple from inspect import getargspec as inspect_getfullargspec -from io import BytesIO as byte_buffer -from io import StringIO as StringIO +from io import BytesIO as byte_buffer, StringIO as StringIO from operator import attrgetter as dottedgetter from typing import Any, Optional, Text @@ -12,21 +11,21 @@ if sys.version_info < (3, 0): import cPickle as pickle from itertools import izip_longest as zip_longest from urllib import ( - quote_plus as quote_plus, - unquote_plus as unquote_plus, quote as quote, + quote_plus as quote_plus, unquote as unquote, + unquote_plus as unquote_plus, ) from urlparse import parse_qsl as parse_qsl else: import pickle as pickle from itertools import zip_longest as zip_longest from urllib.parse import ( - quote_plus as quote_plus, - unquote_plus as unquote_plus, parse_qsl as parse_qsl, quote as quote, + quote_plus as quote_plus, unquote as unquote, + unquote_plus as unquote_plus, ) py36: bool = ... From efce1c2d264568d052baaf79712cc804487d171a Mon Sep 17 00:00:00 2001 From: Wang Date: Tue, 8 Aug 2023 12:35:40 +0800 Subject: [PATCH 3/3] doc: let user use 'pre-commit run' instead of 'black .', 'flake8' and 'usort format .' in pull request template --- .github/pull_request_template.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index e2255f7a..48b8719f 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -2,9 +2,9 @@ **Pre-submission checklist** - [ ] I've ran the following linters locally and fixed lint errors related to the files I modified in this PR - - [ ] `black .` - - [ ] `usort format .` - - [ ] `flake8` + 1. `pip install pre-commit`(If you haven't install pre-commit yet) + 2. `pre-commit install`(If you haven't install the pre-commit script yet.) + 3. `pre-commit run` - [ ] I've installed dev dependencies `pip install -r requirements-dev.txt` and completed the following: - [ ] I've ran tests with `./scripts/run-tests.sh` and made sure all tests are passing