diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-04-05 19:00:19 -0400 |
---|---|---|
committer | mike bayer <mike_mp@zzzcomputing.com> | 2022-04-12 02:09:42 +0000 |
commit | 98eae4e181cb2d1bbc67ec834bfad29dcba7f461 (patch) | |
tree | fc000c3113a4a198b4ddd6bc81fe291dc9ef1ffb /lib/sqlalchemy/testing/plugin/pytestplugin.py | |
parent | 15ef11e0ede82e44fb07f31b63d3db0712d8bf48 (diff) | |
download | sqlalchemy-98eae4e181cb2d1bbc67ec834bfad29dcba7f461.tar.gz |
use code generation for scoped_session
our decorator thing generates code in any case,
so point it at the file itself to generate real code
for the blocks rather than doing things dynamically.
this will allow typing tools to have no problem
whatsoever and we also reduce import time overhead.
file size will be a lot bigger though, shrugs.
syntax / dupe method / etc. checking will be accomplished
by our existing linting / typing / formatting tools.
As we are also using "from __future__ import annotations",
we also no longer have to apply quotes to generated
annotations.
Change-Id: I20962cb65bda63ff0fb67357ab346e9b1ef4f108
Diffstat (limited to 'lib/sqlalchemy/testing/plugin/pytestplugin.py')
-rw-r--r-- | lib/sqlalchemy/testing/plugin/pytestplugin.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/sqlalchemy/testing/plugin/pytestplugin.py b/lib/sqlalchemy/testing/plugin/pytestplugin.py index 6efeac504..ab93e60e2 100644 --- a/lib/sqlalchemy/testing/plugin/pytestplugin.py +++ b/lib/sqlalchemy/testing/plugin/pytestplugin.py @@ -1,9 +1,4 @@ -try: - # installed by bootstrap.py - import sqla_plugin_base as plugin_base -except ImportError: - # assume we're a package, use traditional import - from . import plugin_base +from __future__ import annotations import argparse import collections @@ -17,6 +12,13 @@ import uuid import pytest +try: + # installed by bootstrap.py + import sqla_plugin_base as plugin_base +except ImportError: + # assume we're a package, use traditional import + from . import plugin_base + def pytest_addoption(parser): group = parser.getgroup("sqlalchemy") @@ -565,6 +567,10 @@ def _pytest_fn_decorator(target): from sqlalchemy.util.compat import inspect_getfullargspec def _exec_code_in_env(code, env, fn_name): + # note this is affected by "from __future__ import annotations" at + # the top; exec'ed code will use non-evaluated annotations + # which allows us to be more flexible with code rendering + # in format_argpsec_plus() exec(code, env) return env[fn_name] |