--- /dev/null
+.. change::
+ :tags: bug, typing
+ :tickets: 11782
+
+ Fixed typing issue with :meth:`_sql.Select.with_only_columns`.
)
return woc
- # START OVERLOADED FUNCTIONS self.with_only_columns Select 8
+ # START OVERLOADED FUNCTIONS self.with_only_columns Select 1-8 ", *, maintain_column_froms: bool =..." # noqa: E501
# code within this block is **programmatically,
- # statically generated** by tools/generate_sel_v1_overloads.py
+ # statically generated** by tools/generate_tuple_map_overloads.py
@overload
- def with_only_columns(self, __ent0: _TCCA[_T0]) -> Select[_T0]: ...
+ def with_only_columns(
+ self, __ent0: _TCCA[_T0], /, *, maintain_column_froms: bool = ...
+ ) -> Select[_T0]: ...
@overload
def with_only_columns(
- self, __ent0: _TCCA[_T0], __ent1: _TCCA[_T1]
+ self,
+ __ent0: _TCCA[_T0],
+ __ent1: _TCCA[_T1],
+ /,
+ *,
+ maintain_column_froms: bool = ...,
) -> Select[_T0, _T1]: ...
@overload
def with_only_columns(
- self, __ent0: _TCCA[_T0], __ent1: _TCCA[_T1], __ent2: _TCCA[_T2]
+ self,
+ __ent0: _TCCA[_T0],
+ __ent1: _TCCA[_T1],
+ __ent2: _TCCA[_T2],
+ /,
+ *,
+ maintain_column_froms: bool = ...,
) -> Select[_T0, _T1, _T2]: ...
@overload
__ent1: _TCCA[_T1],
__ent2: _TCCA[_T2],
__ent3: _TCCA[_T3],
+ /,
+ *,
+ maintain_column_froms: bool = ...,
) -> Select[_T0, _T1, _T2, _T3]: ...
@overload
__ent2: _TCCA[_T2],
__ent3: _TCCA[_T3],
__ent4: _TCCA[_T4],
+ /,
+ *,
+ maintain_column_froms: bool = ...,
) -> Select[_T0, _T1, _T2, _T3, _T4]: ...
@overload
__ent3: _TCCA[_T3],
__ent4: _TCCA[_T4],
__ent5: _TCCA[_T5],
+ /,
+ *,
+ maintain_column_froms: bool = ...,
) -> Select[_T0, _T1, _T2, _T3, _T4, _T5]: ...
@overload
__ent4: _TCCA[_T4],
__ent5: _TCCA[_T5],
__ent6: _TCCA[_T6],
+ /,
+ *,
+ maintain_column_froms: bool = ...,
) -> Select[_T0, _T1, _T2, _T3, _T4, _T5, _T6]: ...
@overload
__ent5: _TCCA[_T5],
__ent6: _TCCA[_T6],
__ent7: _TCCA[_T7],
- ) -> Select[_T0, _T1, _T2, _T3, _T4, _T5, _T6, _T7]: ...
+ /,
+ *entities: _ColumnsClauseArgument[Any],
+ maintain_column_froms: bool = ...,
+ ) -> Select[_T0, _T1, _T2, _T3, _T4, _T5, _T6, _T7, Unpack[TupleAny]]: ...
# END OVERLOADED FUNCTIONS self.with_only_columns
.. versionadded:: 2.0
"""
+
# mypy: ignore-errors
from argparse import ArgumentParser
print(
f"{to_reformat} file(s) would be reformatted;",
(
- f"{sum(formatting_error_counts)} formatting errors "
- f"reported in {len(formatting_error_counts)} files"
- )
- if formatting_error_counts
- else "no formatting errors reported",
+ (
+ f"{sum(formatting_error_counts)} formatting errors "
+ f"reported in {len(formatting_error_counts)} files"
+ )
+ if formatting_error_counts
+ else "no formatting errors reported"
+ ),
)
exit(1)
for val in config.get("target_version", [])
if val != "py27"
},
- line_length=config.get("line_length", DEFAULT_LINE_LENGTH)
- if args.project_line_length
- else DEFAULT_LINE_LENGTH,
+ line_length=(
+ config.get("line_length", DEFAULT_LINE_LENGTH)
+ if args.project_line_length
+ else DEFAULT_LINE_LENGTH
+ ),
)
REPORT_ONLY_DOCTEST = args.report_doctest
.. versionadded:: 2.0
"""
+
# mypy: ignore-errors
from __future__ import annotations
return self.sym
-classes: collections.defaultdict[
- str, Dict[str, Tuple[Any, ...]]
-] = collections.defaultdict(dict)
+classes: collections.defaultdict[str, Dict[str, Tuple[Any, ...]]] = (
+ collections.defaultdict(dict)
+)
_T = TypeVar("_T", bound="Any")
if spec.defaults:
new_defaults = tuple(
- _repr_sym("util.EMPTY_DICT")
- if df is util.EMPTY_DICT
- else df
+ (
+ _repr_sym("util.EMPTY_DICT")
+ if df is util.EMPTY_DICT
+ else df
+ )
for df in spec.defaults
)
elem[3] = new_defaults
if spec.kwonlydefaults:
new_kwonlydefaults = {
- name: _repr_sym("util.EMPTY_DICT")
- if df is util.EMPTY_DICT
- else df
+ name: (
+ _repr_sym("util.EMPTY_DICT")
+ if df is util.EMPTY_DICT
+ else df
+ )
for name, df in spec.kwonlydefaults.items()
}
elem[5] = new_kwonlydefaults
from sqlalchemy import util
from sqlalchemy.util import langhelpers
- util.create_proxy_methods = (
- langhelpers.create_proxy_methods
- ) = create_proxy_methods
+ util.create_proxy_methods = langhelpers.create_proxy_methods = (
+ create_proxy_methods
+ )
for entry in entries:
if cmd.args.module in {"all", entry}:
"""Generate inline stubs for generic functions on func
"""
+
# mypy: ignore-errors
from __future__ import annotations
.. versionadded:: 2.0
"""
+
# mypy: ignore-errors
from __future__ import annotations
sys.path.append(str(Path(__file__).parent.parent))
-def process_module(modname: str, filename: str, cmd: code_writer_cmd) -> str:
+def process_module(
+ modname: str, filename: str, expected_number: int, cmd: code_writer_cmd
+) -> str:
# use tempfile in same path as the module, or at least in the
# current working directory, so that black / zimports use
# local pyproject.toml
+ found = 0
with NamedTemporaryFile(
mode="w",
delete=False,
line,
)
if m:
+ found += 1
indent = m.group(1)
given_fnname = current_fnname = m.group(2)
if current_fnname.startswith("self."):
if not in_block:
buf.write(line)
+ if found != expected_number:
+ raise Exception(
+ f"{modname} processed {found}. expected {expected_number}"
+ )
return buf.name
-def run_module(modname: str, cmd: code_writer_cmd) -> None:
+def run_module(modname: str, count: int, cmd: code_writer_cmd) -> None:
cmd.write_status(f"importing module {modname}\n")
mod = importlib.import_module(modname)
destination_path = mod.__file__
assert destination_path is not None
- tempfile = process_module(modname, destination_path, cmd)
+ tempfile = process_module(modname, destination_path, count, cmd)
cmd.run_zimports(tempfile)
cmd.run_black(tempfile)
def main(cmd: code_writer_cmd) -> None:
- for modname in entries:
+ for modname, count in entries:
if cmd.args.module in {"all", modname}:
- run_module(modname, cmd)
+ run_module(modname, count, cmd)
entries = [
- "sqlalchemy.sql._selectable_constructors",
- "sqlalchemy.orm.session",
- "sqlalchemy.orm.query",
- "sqlalchemy.sql.selectable",
- "sqlalchemy.sql.dml",
+ ("sqlalchemy.sql._selectable_constructors", 1),
+ ("sqlalchemy.orm.session", 1),
+ ("sqlalchemy.orm.query", 1),
+ ("sqlalchemy.sql.selectable", 1),
+ ("sqlalchemy.sql.dml", 3),
]
if __name__ == "__main__":
with cmd.add_arguments() as parser:
parser.add_argument(
"--module",
- choices=entries + ["all"],
+ choices=[n for n, _ in entries] + ["all"],
default="all",
help="Which file to generate. Default is to regenerate all files",
)
""" # noqa: E501
+
# mypy: ignore-errors