Skip to content

Mark SQLAlchemy stubs with ignore_missing_stub = false #9653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 42 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
c1545b7
Fix most stubtest_allowlist entries in SQLAlchemy
Avasam Jan 27, 2023
0c2003b
Import typo
Avasam Jan 27, 2023
50190e1
Address some PR comments
Avasam Jan 29, 2023
125c2dd
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 29, 2023
8d659c0
Merge branch 'main' of https://github.com/python/typeshed into sqlalc…
Avasam Jan 30, 2023
9d9647f
Simplified loader_option and register
Avasam Jan 30, 2023
597d925
Tests with showing limitaitons
Avasam Jan 30, 2023
6a5ca2c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 30, 2023
5d35846
Remove test limitation demo
Avasam Jan 30, 2023
edc7bf0
Merge branch 'sqlalchemy-stubtest' of https://github.com/Avasam/types…
Avasam Jan 30, 2023
36952cd
Ensure modern syntax
Avasam Jan 30, 2023
952f8a7
fix pyrigth test_cases
Avasam Jan 30, 2023
724e248
Even better first arg check
Avasam Jan 30, 2023
dc04a31
Fix most stubtest_allowlist entries in SQLAlchemy
Avasam Jan 27, 2023
abc7fe3
Mark SQLAlchemy stubs with `ignore_missing_stub = false`
Avasam Feb 1, 2023
ea917c5
Merge branch 'main' of https://github.com/python/typeshed into sqlalc…
Avasam Feb 1, 2023
5b488d4
Merge branch 'main' into sqlalchemy-stubtest
AlexWaygood Feb 6, 2023
b705170
Merge branch 'main' into sqlalchemy-stubgen
AlexWaygood Feb 7, 2023
2f3c4c1
Merge branch 'main' into sqlalchemy-stubtest
AlexWaygood Feb 7, 2023
99617e7
Merge branch 'main' of https://github.com/python/typeshed into sqlalc…
Avasam Feb 8, 2023
5e7f62d
Merge branch 'sqlalchemy-stubtest' of https://github.com/Avasam/types…
Avasam Feb 8, 2023
710ee2a
Fix new pyright error
Avasam Feb 8, 2023
63e819f
Use a module protocol
Avasam Feb 8, 2023
7f99f3a
Fix stubtest
Avasam Feb 8, 2023
dcb2262
Merge branch 'main' into sqlalchemy-stubtest
Avasam Feb 14, 2023
2ed6302
Merge branch 'main' into sqlalchemy-stubtest
AlexWaygood Mar 16, 2023
e96e15c
Update stubs/SQLAlchemy/sqlalchemy/engine/url.pyi
AlexWaygood Mar 16, 2023
dd69c48
Merge branch 'main' into sqlalchemy-stubtest
Avasam Mar 22, 2023
6e7f6cc
Update usage of Self
Avasam Mar 22, 2023
c3f7651
Merge branch 'sqlalchemy-stubtest' of https://github.com/Avasam/types…
Avasam Mar 22, 2023
e266ef7
Ran stubdefaulter before merge
Avasam Mar 31, 2023
fac6a60
Merge branch 'main' of https://github.com/python/typeshed into sqlalc…
Avasam Mar 31, 2023
88cc978
Ran stubdefaulter before test
Avasam Mar 31, 2023
ad138e7
Update usage of Self
Avasam Mar 31, 2023
d586c7b
Update usage of Unused
Avasam Mar 31, 2023
ee6d6d5
Merge branch 'main' of https://github.com/python/typeshed into sqlalc…
Avasam Mar 31, 2023
800e5e5
Merge branch 'sqlalchemy-stubtest' of https://github.com/Avasam/types…
Avasam Mar 31, 2023
1adf060
Merge branch 'main' of https://github.com/python/typeshed into sqlalc…
Avasam Apr 15, 2023
6b1211e
Row.count and Row.index should not be represetned in stubs
Avasam Apr 15, 2023
c878c6d
Redundant `..sql` in imports
Avasam Apr 16, 2023
cd28b88
Merge branch 'main' of https://github.com/python/typeshed into sqlalc…
Avasam Apr 26, 2023
f302543
pytype exclude sqlalchemy/sql/annotation.pyi
Avasam Apr 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions stubs/SQLAlchemy/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# mypy plugin not supported in typeshed
sqlalchemy.ext.mypy.*
# test suites
sqlalchemy.testing.suite
# Leaked re-exports from the compat module
sqlalchemy.util.quote

# Expanding keyword arguments in stubs
sqlalchemy.ext.declarative.as_declarative

Expand Down Expand Up @@ -25,9 +32,16 @@ sqlalchemy.engine.Connection.engine
sqlalchemy.orm.Mapper.single
sqlalchemy.orm.mapper.Mapper.single

# uses @memoized_property at runtime, but we use @property for compatibility
# Uses @memoized_property at runtime, but we use @property for compatibility
sqlalchemy.engine.URL.normalized_query
sqlalchemy.engine.url.URL.normalized_query
# Uses @memoized_property, but that causes regr_test to raise 'Cannot determine type of "..." in base class "..." [misc]'
sqlalchemy.schema.SchemaItem.info
sqlalchemy.sql.elements.AnnotatedColumnElement.info
sqlalchemy.sql.elements.AnnotatedColumnElement.key
sqlalchemy.sql.elements.AnnotatedColumnElement.name
sqlalchemy.sql.elements.AnnotatedColumnElement.table
sqlalchemy.sql.schema.SchemaItem.info

# runtime has extra internal arguments that are inconsistent across micro versions
sqlalchemy.testing.engines.testing_engine
Expand Down Expand Up @@ -62,8 +76,10 @@ sqlalchemy.sql.quoted_name.upper
sqlalchemy.orm.ColumnProperty.Comparator.__clause_element__
sqlalchemy.orm.properties.ColumnProperty.Comparator.__clause_element__

# Same error as in stdlib due to it being re-erported
# Same error as in stdlib due to it being re-exported
sqlalchemy.dialects.mysql.asyncmy.AsyncAdapt_asyncmy_dbapi.Binary
sqlalchemy.util.compat.StringIO.seek
sqlalchemy.util.compat.StringIO.truncate
sqlalchemy.util.StringIO.seek
sqlalchemy.util.StringIO.truncate
sqlalchemy.testing.mock.patch
1 change: 1 addition & 0 deletions stubs/SQLAlchemy/@tests/test_cases/check_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@ def no_args(__foo: Foo) -> None:
prepare_for_drop_tables(url, unused)
stop_test_class_outside_fixtures(url, unused, type)
get_temp_table_name(url, unused, "")
set_default_schema_on_connection(url, unused, unused)
set_default_schema_on_connection(ConfigModule, unused, unused)
set_default_schema_on_connection(config, unused, unused)
1 change: 0 additions & 1 deletion stubs/SQLAlchemy/METADATA.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ obsolete_since = "2.0.0" # Released on 2023-01-26

[tool.stubtest]
stubtest_requirements = ["pytest"]
ignore_missing_stub = true
2 changes: 1 addition & 1 deletion stubs/SQLAlchemy/sqlalchemy/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ from .sql import (
values as values,
within_group as within_group,
)
from .types import (
from .sql.sqltypes import (
ARRAY as ARRAY,
BIGINT as BIGINT,
BINARY as BINARY,
Expand Down
15 changes: 15 additions & 0 deletions stubs/SQLAlchemy/sqlalchemy/cprocessors.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class DecimalResultProcessor:
def __init__(self, *args, **kwargs) -> None: ...
def process(self, *args, **kwargs): ...

class UnicodeResultProcessor:
def __init__(self, *args, **kwargs) -> None: ...
def conditional_process(self, *args, **kwargs): ...
def process(self, *args, **kwargs): ...

def int_to_boolean(*args, **kwargs): ...
def str_to_date(*args, **kwargs): ...
def str_to_datetime(*args, **kwargs): ...
def str_to_time(*args, **kwargs): ...
def to_float(*args, **kwargs): ...
def to_str(*args, **kwargs): ...
2 changes: 1 addition & 1 deletion stubs/SQLAlchemy/sqlalchemy/dialects/firebird/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any

from sqlalchemy.dialects.firebird.base import (
from .base import (
BIGINT as BIGINT,
BLOB as BLOB,
CHAR as CHAR,
Expand Down
13 changes: 6 additions & 7 deletions stubs/SQLAlchemy/sqlalchemy/dialects/firebird/base.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from _typeshed import Incomplete
from typing import Any

from sqlalchemy import sql, types as sqltypes
from sqlalchemy.engine import default
from sqlalchemy.sql import compiler
from sqlalchemy.types import (
from ...engine import default
from ...sql import compiler, sqltypes
from ...sql.sqltypes import (
BIGINT as BIGINT,
BLOB as BLOB,
DATE as DATE,
Expand Down Expand Up @@ -46,7 +45,7 @@ class FBTypeCompiler(compiler.GenericTypeCompiler):
def visit_CHAR(self, type_, **kw): ...
def visit_VARCHAR(self, type_, **kw): ...

class FBCompiler(sql.compiler.SQLCompiler):
class FBCompiler(compiler.SQLCompiler):
ansi_bind_rules: bool
def visit_now_func(self, fn, **kw): ...
def visit_startswith_op_binary(self, binary, operator, **kw): ...
Expand All @@ -63,12 +62,12 @@ class FBCompiler(sql.compiler.SQLCompiler):
def limit_clause(self, select, **kw): ...
def returning_clause(self, stmt, returning_cols): ...

class FBDDLCompiler(sql.compiler.DDLCompiler):
class FBDDLCompiler(compiler.DDLCompiler):
def visit_create_sequence(self, create): ...
def visit_drop_sequence(self, drop): ...
def visit_computed_column(self, generated): ...

class FBIdentifierPreparer(sql.compiler.IdentifierPreparer):
class FBIdentifierPreparer(compiler.IdentifierPreparer):
reserved_words: Any
illegal_initial_characters: Any
def __init__(self, dialect) -> None: ...
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from _typeshed import Incomplete
from typing import Any

from ...types import Float, Numeric
from ...sql.sqltypes import Float, Numeric
from .base import FBDialect, FBExecutionContext

class _kinterbasdb_numeric:
Expand Down
6 changes: 2 additions & 4 deletions stubs/SQLAlchemy/sqlalchemy/dialects/mssql/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ from _typeshed import Incomplete
from typing import Any, overload
from typing_extensions import Literal

import sqlalchemy.types as sqltypes

from ...engine import default
from ...sql import compiler
from ...sql import compiler, sqltypes
from ...sql.elements import Cast
from ...types import (
from ...sql.sqltypes import (
BIGINT as BIGINT,
BINARY as BINARY,
CHAR as CHAR,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Any

from ...sql import expression
from ...types import TypeDecorator
from ...sql.type_api import TypeDecorator

ischema: Any

Expand Down
2 changes: 1 addition & 1 deletion stubs/SQLAlchemy/sqlalchemy/dialects/mssql/json.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ...types import JSON as _JSON
from ...sql.sqltypes import JSON as _JSON

class JSON(_JSON): ...

Expand Down
2 changes: 1 addition & 1 deletion stubs/SQLAlchemy/sqlalchemy/dialects/mssql/pymssql.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any

from ...types import Numeric
from ...sql.sqltypes import Numeric
from .base import MSDialect, MSIdentifierPreparer

class _MSNumeric_pymssql(Numeric):
Expand Down
2 changes: 1 addition & 1 deletion stubs/SQLAlchemy/sqlalchemy/dialects/mssql/pyodbc.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from _typeshed import Incomplete
from typing import Any

from ...connectors.pyodbc import PyODBCConnector
from ...types import DateTime, Float, Numeric
from ...sql.sqltypes import DateTime, Float, Numeric
from .base import BINARY, DATETIMEOFFSET, VARBINARY, MSDialect, MSExecutionContext

class _ms_numeric_pyodbc:
Expand Down
14 changes: 12 additions & 2 deletions stubs/SQLAlchemy/sqlalchemy/dialects/mysql/asyncmy.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from _typeshed import Incomplete
from typing import Any
from _typeshed import Incomplete, ReadableBuffer
from collections.abc import Iterable
from typing import Any, SupportsBytes
from typing_extensions import SupportsIndex

from ...engine import AdaptedConnection
from .pymysql import MySQLDialect_pymysql
Expand Down Expand Up @@ -51,10 +53,18 @@ class AsyncAdapt_asyncmy_connection(AdaptedConnection):
class AsyncAdaptFallback_asyncmy_connection(AsyncAdapt_asyncmy_connection):
await_: Any

def _Binary(x: Iterable[SupportsIndex] | SupportsIndex | SupportsBytes | ReadableBuffer) -> bytes: ...

class AsyncAdapt_asyncmy_dbapi:
asyncmy: Any
pymysql: Any
paramstyle: str
STRING: Incomplete
NUMBER: Incomplete
BINARY: Incomplete
DATETIME: Incomplete
TIMESTAMP: Incomplete
Binary = staticmethod(_Binary)
def __init__(self, asyncmy: Any) -> None: ...
def connect(self, *arg, **kw): ...

Expand Down
3 changes: 2 additions & 1 deletion stubs/SQLAlchemy/sqlalchemy/dialects/mysql/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ from typing import Any

from ...engine import default
from ...sql import compiler
from ...types import BINARY as BINARY, BLOB as BLOB, BOOLEAN as BOOLEAN, DATE as DATE, VARBINARY as VARBINARY
from ...sql.sqltypes import BINARY as BINARY, BLOB as BLOB, BOOLEAN as BOOLEAN, DATE as DATE, VARBINARY as VARBINARY
from .enumerated import ENUM as ENUM, SET as SET
from .json import JSON as JSON
from .reserved_words import RESERVED_WORDS_MARIADB as RESERVED_WORDS_MARIADB, RESERVED_WORDS_MYSQL as RESERVED_WORDS_MYSQL
from .types import (
BIGINT as BIGINT,
BIT as BIT,
Expand Down
2 changes: 1 addition & 1 deletion stubs/SQLAlchemy/sqlalchemy/dialects/mysql/dml.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from typing import Any

from ...sql.dml import Insert as StandardInsert
from ...sql.elements import ClauseElement
from ...util import memoized_property
from ...util.langhelpers import memoized_property

class Insert(StandardInsert):
stringify_dialect: str
Expand Down
2 changes: 1 addition & 1 deletion stubs/SQLAlchemy/sqlalchemy/dialects/mysql/json.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sqlalchemy.types as sqltypes
from ...sql import sqltypes

class JSON(sqltypes.JSON): ...

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any

from ...util import memoized_property
from ...util.langhelpers import memoized_property
from .base import BIT, MySQLCompiler, MySQLDialect, MySQLIdentifierPreparer

class MySQLCompiler_mysqlconnector(MySQLCompiler):
Expand Down
2 changes: 1 addition & 1 deletion stubs/SQLAlchemy/sqlalchemy/dialects/mysql/mysqldb.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from _typeshed import Incomplete
from typing import Any

from ...util import memoized_property
from ...util.langhelpers import memoized_property
from .base import MySQLCompiler, MySQLDialect, MySQLExecutionContext

class MySQLExecutionContext_mysqldb(MySQLExecutionContext):
Expand Down
2 changes: 1 addition & 1 deletion stubs/SQLAlchemy/sqlalchemy/dialects/mysql/pymysql.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from _typeshed import Incomplete
from typing import Any

from ...util import memoized_property
from ...util.langhelpers import memoized_property
from .mysqldb import MySQLDialect_mysqldb

class MySQLDialect_pymysql(MySQLDialect_mysqldb):
Expand Down
2 changes: 1 addition & 1 deletion stubs/SQLAlchemy/sqlalchemy/dialects/mysql/types.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from _typeshed import Incomplete
from typing import Any

import sqlalchemy.types as sqltypes
from ...sql import sqltypes

class _NumericType:
unsigned: Any
Expand Down
6 changes: 2 additions & 4 deletions stubs/SQLAlchemy/sqlalchemy/dialects/oracle/base.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from _typeshed import Incomplete
from typing import Any

from sqlalchemy.sql import ClauseElement

from ...engine import default
from ...sql import compiler, sqltypes
from ...types import (
from ...sql import ClauseElement, compiler, sqltypes
from ...sql.sqltypes import (
BLOB as BLOB,
CHAR as CHAR,
CLOB as CLOB,
Expand Down
3 changes: 1 addition & 2 deletions stubs/SQLAlchemy/sqlalchemy/dialects/oracle/cx_oracle.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from _typeshed import Incomplete
from typing import Any

import sqlalchemy.types as sqltypes

from ...sql import sqltypes
from . import base as oracle
from .base import OracleCompiler, OracleDialect, OracleExecutionContext

Expand Down
4 changes: 1 addition & 3 deletions stubs/SQLAlchemy/sqlalchemy/dialects/postgresql/array.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from _typeshed import Incomplete
from typing import Any as _Any

import sqlalchemy.types as sqltypes

from ...sql import expression
from ...sql import expression, sqltypes

def Any(other, arrexpr, operator=...): ...
def All(other, arrexpr, operator=...): ...
Expand Down
3 changes: 3 additions & 0 deletions stubs/SQLAlchemy/sqlalchemy/dialects/postgresql/asyncpg.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class AsyncAdapt_asyncpg_connection(AdaptedConnection):
def rollback(self) -> None: ...
def commit(self) -> None: ...
def close(self) -> None: ...
def terminate(self) -> None: ...

class AsyncAdaptFallback_asyncpg_connection(AsyncAdapt_asyncpg_connection):
await_: Any
Expand Down Expand Up @@ -152,6 +153,7 @@ class AsyncAdapt_asyncpg_dbapi:
TIMESTAMP: Any
TIMESTAMP_W_TZ: Any
TIME: Any
TIME_W_TZ: Incomplete
DATE: Any
INTERVAL: Any
NUMBER: Any
Expand All @@ -175,6 +177,7 @@ class PGDialect_asyncpg(PGDialect):
supports_unicode_statements: bool
supports_server_side_cursors: bool
supports_unicode_binds: bool
has_terminate: bool
default_paramstyle: str
supports_sane_multi_rowcount: bool
statement_compiler: Any
Expand Down
3 changes: 2 additions & 1 deletion stubs/SQLAlchemy/sqlalchemy/dialects/postgresql/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ from ...engine import characteristics, default, reflection
from ...schema import _CreateDropBase
from ...sql import compiler, elements, sqltypes
from ...sql.ddl import DDLBase
from ...types import (
from ...sql.sqltypes import (
BIGINT as BIGINT,
BOOLEAN as BOOLEAN,
CHAR as CHAR,
Expand Down Expand Up @@ -179,6 +179,7 @@ class PGTypeCompiler(compiler.GenericTypeCompiler):
def visit_INET(self, type_, **kw): ...
def visit_CIDR(self, type_, **kw): ...
def visit_MACADDR(self, type_, **kw): ...
def visit_MACADDR8(self, type_, **kw): ...
def visit_MONEY(self, type_, **kw): ...
def visit_OID(self, type_, **kw): ...
def visit_REGCLASS(self, type_, **kw): ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/SQLAlchemy/sqlalchemy/dialects/postgresql/dml.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ from typing import Any

from ...sql.dml import Insert as StandardInsert
from ...sql.elements import ClauseElement
from ...util import memoized_property
from ...util.langhelpers import memoized_property

class Insert(StandardInsert):
stringify_dialect: str
Expand Down
4 changes: 1 addition & 3 deletions stubs/SQLAlchemy/sqlalchemy/dialects/postgresql/hstore.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from _typeshed import Incomplete
from typing import Any

import sqlalchemy.types as sqltypes

from ...sql import functions as sqlfunc
from ...sql import functions as sqlfunc, sqltypes

class HSTORE(sqltypes.Indexable, sqltypes.Concatenable, sqltypes.TypeEngine):
__visit_name__: str
Expand Down
2 changes: 1 addition & 1 deletion stubs/SQLAlchemy/sqlalchemy/dialects/postgresql/json.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from _typeshed import Incomplete
from typing import Any

import sqlalchemy.types as sqltypes
from ...sql import sqltypes

class JSONPathType(sqltypes.JSON.JSONPathType):
def bind_processor(self, dialect): ...
Expand Down
3 changes: 1 addition & 2 deletions stubs/SQLAlchemy/sqlalchemy/dialects/postgresql/pg8000.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from _typeshed import Incomplete
from typing import Any

import sqlalchemy.types as sqltypes

from ...sql import sqltypes
from .array import ARRAY as PGARRAY
from .base import ENUM, INTERVAL, UUID, PGCompiler, PGDialect, PGExecutionContext, PGIdentifierPreparer
from .json import JSON, JSONB, JSONPathType
Expand Down
3 changes: 1 addition & 2 deletions stubs/SQLAlchemy/sqlalchemy/dialects/postgresql/psycopg2.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from _typeshed import Incomplete
from typing import Any

import sqlalchemy.types as sqltypes

from ...sql import sqltypes
from .array import ARRAY as PGARRAY
from .base import ENUM, UUID, PGCompiler, PGDialect, PGExecutionContext, PGIdentifierPreparer
from .hstore import HSTORE
Expand Down
Loading