-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix all fixable stubtest_allowlist entries in SQLAlchemy (#9596)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
- Loading branch information
1 parent
08e6e4c
commit b0ed50e
Showing
23 changed files
with
379 additions
and
1,268 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
from __future__ import annotations | ||
|
||
from typing_extensions import assert_type | ||
|
||
from sqlalchemy.orm.strategy_options import ( | ||
Load, | ||
contains_eager, | ||
defaultload, | ||
defer, | ||
immediateload, | ||
joinedload, | ||
lazyload, | ||
load_only, | ||
loader_option, | ||
noload, | ||
raiseload, | ||
selectin_polymorphic, | ||
selectinload, | ||
subqueryload, | ||
undefer, | ||
undefer_group, | ||
with_expression, | ||
) | ||
|
||
|
||
def fn(loadopt: Load, *args: object) -> loader_option: | ||
return loader_option() | ||
|
||
|
||
# Testing that the function and return type of function are actually all instances of "loader_option" | ||
assert_type(contains_eager, loader_option) | ||
assert_type(contains_eager(fn), loader_option) | ||
assert_type(load_only, loader_option) | ||
assert_type(load_only(fn), loader_option) | ||
assert_type(joinedload, loader_option) | ||
assert_type(joinedload(fn), loader_option) | ||
assert_type(subqueryload, loader_option) | ||
assert_type(subqueryload(fn), loader_option) | ||
assert_type(selectinload, loader_option) | ||
assert_type(selectinload(fn), loader_option) | ||
assert_type(lazyload, loader_option) | ||
assert_type(lazyload(fn), loader_option) | ||
assert_type(immediateload, loader_option) | ||
assert_type(immediateload(fn), loader_option) | ||
assert_type(noload, loader_option) | ||
assert_type(noload(fn), loader_option) | ||
assert_type(raiseload, loader_option) | ||
assert_type(raiseload(fn), loader_option) | ||
assert_type(defaultload, loader_option) | ||
assert_type(defaultload(fn), loader_option) | ||
assert_type(defer, loader_option) | ||
assert_type(defer(fn), loader_option) | ||
assert_type(undefer, loader_option) | ||
assert_type(undefer(fn), loader_option) | ||
assert_type(undefer_group, loader_option) | ||
assert_type(undefer_group(fn), loader_option) | ||
assert_type(with_expression, loader_option) | ||
assert_type(with_expression(fn), loader_option) | ||
assert_type(selectin_polymorphic, loader_option) | ||
assert_type(selectin_polymorphic(fn), loader_option) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
from __future__ import annotations | ||
|
||
from _typeshed.dbapi import DBAPIConnection | ||
from typing import cast | ||
|
||
from sqlalchemy.engine.base import Engine | ||
from sqlalchemy.engine.default import DefaultDialect | ||
from sqlalchemy.engine.url import URL | ||
from sqlalchemy.pool.base import Pool | ||
from sqlalchemy.testing import config as ConfigModule | ||
from sqlalchemy.testing.provision import ( | ||
configure_follower, | ||
create_db, | ||
drop_all_schema_objects_post_tables, | ||
drop_all_schema_objects_pre_tables, | ||
drop_db, | ||
follower_url_from_main, | ||
generate_driver_url, | ||
get_temp_table_name, | ||
post_configure_engine, | ||
prepare_for_drop_tables, | ||
register, | ||
run_reap_dbs, | ||
set_default_schema_on_connection, | ||
stop_test_class_outside_fixtures, | ||
temp_table_keyword_args, | ||
update_db_opts, | ||
) | ||
from sqlalchemy.util import immutabledict | ||
|
||
url = URL("", "", "", "", 0, "", immutabledict()) | ||
engine = Engine(Pool(lambda: cast(DBAPIConnection, object())), DefaultDialect(), "") | ||
config = cast(ConfigModule.Config, object()) | ||
unused = None | ||
|
||
|
||
class Foo: | ||
pass | ||
|
||
|
||
# Test that the decorator changes the first parameter to "cfg: str | URL | _ConfigProtocol" | ||
@register.init | ||
def no_args(__foo: Foo) -> None: | ||
pass | ||
|
||
|
||
no_args(cfg="") | ||
no_args(cfg=url) | ||
no_args(cfg=config) | ||
|
||
# Test pre-decorated functions | ||
generate_driver_url(url, "", "") | ||
drop_all_schema_objects_pre_tables(url, unused) | ||
drop_all_schema_objects_post_tables(url, unused) | ||
create_db(url, engine, unused) | ||
drop_db(url, engine, unused) | ||
update_db_opts(url, unused) | ||
post_configure_engine(url, unused, unused) | ||
follower_url_from_main(url, "") | ||
configure_follower(url, unused) | ||
run_reap_dbs(url, unused) | ||
temp_table_keyword_args(url, engine) | ||
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(ConfigModule, unused, unused) | ||
set_default_schema_on_connection(config, unused, unused) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.