code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def _guess_if_default_is_unparenthesized_sql_expr( self, expr: Optional[str] ) -> bool: """Determine if a server default is a SQL expression or a constant. There are too many assertions that expect server defaults to round-trip identically without parenthesis added so we will add pa...
Determine if a server default is a SQL expression or a constant. There are too many assertions that expect server defaults to round-trip identically without parenthesis added so we will add parens only in very specific cases.
_guess_if_default_is_unparenthesized_sql_expr
python
sqlalchemy/alembic
alembic/ddl/sqlite.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/ddl/sqlite.py
MIT
def __init__( self, migration_context: MigrationContext, impl: Optional[BatchOperationsImpl] = None, ) -> None: """Construct a new :class:`.Operations` :param migration_context: a :class:`.MigrationContext` instance. """ self.migration_context = mig...
Construct a new :class:`.Operations` :param migration_context: a :class:`.MigrationContext` instance.
__init__
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def register_operation( cls, name: str, sourcename: Optional[str] = None ) -> Callable[[Type[_T]], Type[_T]]: """Register a new operation for this class. This method is normally used to add new operations to the :class:`.Operations` class, and possibly the :class:`.BatchOper...
Register a new operation for this class. This method is normally used to add new operations to the :class:`.Operations` class, and possibly the :class:`.BatchOperations` class as well. All Alembic migration operations are implemented via this system, however the system is also...
register_operation
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def implementation_for(cls, op_cls: Any) -> Callable[[_C], _C]: """Register an implementation for a given :class:`.MigrateOperation`. This is part of the operation extensibility API. .. seealso:: :ref:`operation_plugins` - example of use """ def decorate(fn: _C) ...
Register an implementation for a given :class:`.MigrateOperation`. This is part of the operation extensibility API. .. seealso:: :ref:`operation_plugins` - example of use
implementation_for
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def invoke(self, operation: MigrateOperation) -> Any: """Given a :class:`.MigrateOperation`, invoke it in terms of this :class:`.Operations` instance. """ fn = self._to_impl.dispatch( operation, self.migration_context.impl.__dialect__ ) return fn(self, operat...
Given a :class:`.MigrateOperation`, invoke it in terms of this :class:`.Operations` instance.
invoke
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def inline_literal( self, value: Union[str, int], type_: Optional[TypeEngine[Any]] = None ) -> _literal_bindparam: r"""Produce an 'inline literal' expression, suitable for using in an INSERT, UPDATE, or DELETE statement. When using Alembic in "offline" mode, CRUD operations ...
Produce an 'inline literal' expression, suitable for using in an INSERT, UPDATE, or DELETE statement. When using Alembic in "offline" mode, CRUD operations aren't compatible with SQLAlchemy's default behavior surrounding literal values, which is that they are converted into boun...
inline_literal
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def run_async( self, async_function: Callable[..., Awaitable[_T]], *args: Any, **kw_args: Any, ) -> _T: """Invoke the given asynchronous callable, passing an asynchronous :class:`~sqlalchemy.ext.asyncio.AsyncConnection` as the first argument. This met...
Invoke the given asynchronous callable, passing an asynchronous :class:`~sqlalchemy.ext.asyncio.AsyncConnection` as the first argument. This method allows calling async functions from within the synchronous ``upgrade()`` or ``downgrade()`` alembic migration method. The ...
run_async
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def create_index( self, index_name: Optional[str], table_name: str, columns: Sequence[Union[str, TextClause, ColumnElement[Any]]], *, schema: Optional[str] = None, unique: bool = False, if_not_exists: Optional[bool] = None, ...
Issue a "create index" instruction using the current migration context. e.g.:: from alembic import op op.create_index("ik_test", "t1", ["foo", "bar"]) Functional indexes can be produced by using the :func:`sqlalchemy.sql.expression.text...
create_index
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def create_table( self, table_name: str, *columns: SchemaItem, if_not_exists: Optional[bool] = None, **kw: Any, ) -> Table: r"""Issue a "create table" instruction using the current migration context. This directive ...
Issue a "create table" instruction using the current migration context. This directive receives an argument list similar to that of the traditional :class:`sqlalchemy.schema.Table` construct, but without the metadata:: from sqlalchemy import INTEGER, VAR...
create_table
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def drop_column( self, table_name: str, column_name: str, *, schema: Optional[str] = None, **kw: Any, ) -> None: """Issue a "drop column" instruction using the current migration context. e.g.:: ...
Issue a "drop column" instruction using the current migration context. e.g.:: drop_column("organization", "account_id") :param table_name: name of table :param column_name: name of column :param schema: Optional schema name to operate within...
drop_column
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def drop_constraint( self, constraint_name: str, table_name: str, type_: Optional[str] = None, *, schema: Optional[str] = None, if_exists: Optional[bool] = None, ) -> None: r"""Drop a constraint of the given name, ty...
Drop a constraint of the given name, typically via DROP CONSTRAINT. :param constraint_name: name of the constraint. :param table_name: table name. :param type\_: optional, required on MySQL. can be 'foreignkey', 'primary', 'unique', or 'check'. :param schem...
drop_constraint
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def drop_index( self, index_name: str, table_name: Optional[str] = None, *, schema: Optional[str] = None, if_exists: Optional[bool] = None, **kw: Any, ) -> None: r"""Issue a "drop index" instruction using the current...
Issue a "drop index" instruction using the current migration context. e.g.:: drop_index("accounts") :param index_name: name of the index. :param table_name: name of the owning table. Some backends such as Microsoft SQL Server require this....
drop_index
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def drop_table( self, table_name: str, *, schema: Optional[str] = None, if_exists: Optional[bool] = None, **kw: Any, ) -> None: r"""Issue a "drop table" instruction using the current migration context. ...
Issue a "drop table" instruction using the current migration context. e.g.:: drop_table("accounts") :param table_name: Name of the table :param schema: Optional schema name to operate within. To control quoting of the schema outside of th...
drop_table
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def drop_table_comment( self, table_name: str, *, existing_comment: Optional[str] = None, schema: Optional[str] = None, ) -> None: """Issue a "drop table comment" operation to remove an existing comment set on a table. ...
Issue a "drop table comment" operation to remove an existing comment set on a table. :param table_name: string name of the target table. :param existing_comment: An optional string value of a comment already registered on the specified table. .. seealso:: ...
drop_table_comment
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def add_column( self, column: Column[Any], *, insert_before: Optional[str] = None, insert_after: Optional[str] = None, if_not_exists: Optional[bool] = None, ) -> None: """Issue an "add column" instruction using the current ...
Issue an "add column" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.add_column`
add_column
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def create_exclude_constraint( self, constraint_name: str, *elements: Any, **kw: Any ) -> Optional[Table]: """Issue a "create exclude constraint" instruction using the current batch migration context. .. note:: This method is Postgresql specific, and additionall...
Issue a "create exclude constraint" instruction using the current batch migration context. .. note:: This method is Postgresql specific, and additionally requires at least SQLAlchemy 1.0. .. seealso:: :meth:`.Operations.create_exclude_constraint` ...
create_exclude_constraint
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def create_index( self, index_name: str, columns: List[str], **kw: Any ) -> None: """Issue a "create index" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.create_index` """ # noqa: E501 ...
Issue a "create index" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.create_index`
create_index
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def drop_column(self, column_name: str, **kw: Any) -> None: """Issue a "drop column" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.drop_column` """ # noqa: E501 ...
Issue a "drop column" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.drop_column`
drop_column
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def drop_index(self, index_name: str, **kw: Any) -> None: """Issue a "drop index" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.drop_index` """ # noqa: E501 ...
Issue a "drop index" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.drop_index`
drop_index
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def drop_table_comment( self, *, existing_comment: Optional[str] = None ) -> None: """Issue a "drop table comment" operation to remove an existing comment set on a table using the current batch operations context. :param existing_comment: An optional ...
Issue a "drop table comment" operation to remove an existing comment set on a table using the current batch operations context. :param existing_comment: An optional string value of a comment already registered on the specified table.
drop_table_comment
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def execute( self, sqltext: Union[Executable, str], *, execution_options: Optional[dict[str, Any]] = None, ) -> None: """Execute the given SQL using the current migration context. .. seealso:: :meth:`.Operations.execute` ...
Execute the given SQL using the current migration context. .. seealso:: :meth:`.Operations.execute`
execute
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def create_column_comment(self, column): """the batch table creation function will issue create_column_comment on the real "impl" as part of the create table process. That is, the Column object will have the comment on it already, so when it is received by add_column() it will be a norm...
the batch table creation function will issue create_column_comment on the real "impl" as part of the create table process. That is, the Column object will have the comment on it already, so when it is received by add_column() it will be a normal part of the CREATE TABLE and doesn't need...
create_column_comment
python
sqlalchemy/alembic
alembic/operations/batch.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/batch.py
MIT
def create_table_comment(self, table): """the batch table creation function will issue create_table_comment on the real "impl" as part of the create table process. """
the batch table creation function will issue create_table_comment on the real "impl" as part of the create table process.
create_table_comment
python
sqlalchemy/alembic
alembic/operations/batch.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/batch.py
MIT
def drop_table_comment(self, table): """the batch table creation function will issue drop_table_comment on the real "impl" as part of the create table process. """
the batch table creation function will issue drop_table_comment on the real "impl" as part of the create table process.
drop_table_comment
python
sqlalchemy/alembic
alembic/operations/batch.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/batch.py
MIT
def drop_constraint( cls, operations: Operations, constraint_name: str, table_name: str, type_: Optional[str] = None, *, schema: Optional[str] = None, if_exists: Optional[bool] = None, ) -> None: r"""Drop a constraint of the given name, typical...
Drop a constraint of the given name, typically via DROP CONSTRAINT. :param constraint_name: name of the constraint. :param table_name: table name. :param type\_: optional, required on MySQL. can be 'foreignkey', 'primary', 'unique', or 'check'. :param schema: Optional schema n...
drop_constraint
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def create_index( cls, operations: Operations, index_name: Optional[str], table_name: str, columns: Sequence[Union[str, TextClause, ColumnElement[Any]]], *, schema: Optional[str] = None, unique: bool = False, if_not_exists: Optional[bool] = None, ...
Issue a "create index" instruction using the current migration context. e.g.:: from alembic import op op.create_index("ik_test", "t1", ["foo", "bar"]) Functional indexes can be produced by using the :func:`sqlalchemy.sql.expression.text` construct:: ...
create_index
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def batch_create_index( cls, operations: BatchOperations, index_name: str, columns: List[str], **kw: Any, ) -> None: """Issue a "create index" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.create_i...
Issue a "create index" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.create_index`
batch_create_index
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def drop_index( cls, operations: Operations, index_name: str, table_name: Optional[str] = None, *, schema: Optional[str] = None, if_exists: Optional[bool] = None, **kw: Any, ) -> None: r"""Issue a "drop index" instruction using the current ...
Issue a "drop index" instruction using the current migration context. e.g.:: drop_index("accounts") :param index_name: name of the index. :param table_name: name of the owning table. Some backends such as Microsoft SQL Server require this. :param schema: ...
drop_index
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def batch_drop_index( cls, operations: BatchOperations, index_name: str, **kw: Any ) -> None: """Issue a "drop index" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.drop_index` """ op = cls( index_nam...
Issue a "drop index" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.drop_index`
batch_drop_index
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def create_table( cls, operations: Operations, table_name: str, *columns: SchemaItem, if_not_exists: Optional[bool] = None, **kw: Any, ) -> Table: r"""Issue a "create table" instruction using the current migration context. This directive recei...
Issue a "create table" instruction using the current migration context. This directive receives an argument list similar to that of the traditional :class:`sqlalchemy.schema.Table` construct, but without the metadata:: from sqlalchemy import INTEGER, VARCHAR, NVARCHAR, Colu...
create_table
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def drop_table( cls, operations: Operations, table_name: str, *, schema: Optional[str] = None, if_exists: Optional[bool] = None, **kw: Any, ) -> None: r"""Issue a "drop table" instruction using the current migration context. e.g.:: ...
Issue a "drop table" instruction using the current migration context. e.g.:: drop_table("accounts") :param table_name: Name of the table :param schema: Optional schema name to operate within. To control quoting of the schema outside of the default behavior, use ...
drop_table
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def reverse(self) -> Union[CreateTableCommentOp, DropTableCommentOp]: """Reverses the COMMENT ON operation against a table.""" if self.existing_comment is None: return DropTableCommentOp( self.table_name, existing_comment=self.comment, schema=s...
Reverses the COMMENT ON operation against a table.
reverse
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def drop_table_comment( cls, operations: Operations, table_name: str, *, existing_comment: Optional[str] = None, schema: Optional[str] = None, ) -> None: """Issue a "drop table comment" operation to remove an existing comment set on a table. :...
Issue a "drop table comment" operation to remove an existing comment set on a table. :param table_name: string name of the target table. :param existing_comment: An optional string value of a comment already registered on the specified table. .. seealso:: :meth:`....
drop_table_comment
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def batch_drop_table_comment( cls, operations: BatchOperations, *, existing_comment: Optional[str] = None, ) -> None: """Issue a "drop table comment" operation to remove an existing comment set on a table using the current batch operations context. :p...
Issue a "drop table comment" operation to remove an existing comment set on a table using the current batch operations context. :param existing_comment: An optional string value of a comment already registered on the specified table.
batch_drop_table_comment
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def batch_add_column( cls, operations: BatchOperations, column: Column[Any], *, insert_before: Optional[str] = None, insert_after: Optional[str] = None, if_not_exists: Optional[bool] = None, ) -> None: """Issue an "add column" instruction using the cur...
Issue an "add column" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.add_column`
batch_add_column
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def drop_column( cls, operations: Operations, table_name: str, column_name: str, *, schema: Optional[str] = None, **kw: Any, ) -> None: """Issue a "drop column" instruction using the current migration context. e.g.:: drop_...
Issue a "drop column" instruction using the current migration context. e.g.:: drop_column("organization", "account_id") :param table_name: name of table :param column_name: name of column :param schema: Optional schema name to operate within. To control q...
drop_column
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def batch_drop_column( cls, operations: BatchOperations, column_name: str, **kw: Any ) -> None: """Issue a "drop column" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.drop_column` """ op = cls( operat...
Issue a "drop column" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.drop_column`
batch_drop_column
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def batch_execute( cls, operations: Operations, sqltext: Union[Executable, str], *, execution_options: Optional[dict[str, Any]] = None, ) -> None: """Execute the given SQL using the current migration context. .. seealso:: :meth:`.Operations.execu...
Execute the given SQL using the current migration context. .. seealso:: :meth:`.Operations.execute`
batch_execute
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def upgrade_ops(self) -> Optional[UpgradeOps]: """An instance of :class:`.UpgradeOps`. .. seealso:: :attr:`.MigrationScript.upgrade_ops_list` """ if len(self._upgrade_ops) > 1: raise ValueError( "This MigrationScript instance has a multiple-entry...
An instance of :class:`.UpgradeOps`. .. seealso:: :attr:`.MigrationScript.upgrade_ops_list`
upgrade_ops
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def downgrade_ops(self) -> Optional[DowngradeOps]: """An instance of :class:`.DowngradeOps`. .. seealso:: :attr:`.MigrationScript.downgrade_ops_list` """ if len(self._downgrade_ops) > 1: raise ValueError( "This MigrationScript instance has a mult...
An instance of :class:`.DowngradeOps`. .. seealso:: :attr:`.MigrationScript.downgrade_ops_list`
downgrade_ops
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def _ensure_table_for_fk(self, metadata: MetaData, fk: ForeignKey) -> None: """create a placeholder Table object for the referent of a ForeignKey. """ if isinstance(fk._colspec, str): table_key, cname = fk._colspec.rsplit(".", 1) sname, tname = self._parse_table_...
create a placeholder Table object for the referent of a ForeignKey.
_ensure_table_for_fk
python
sqlalchemy/alembic
alembic/operations/schemaobj.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/schemaobj.py
MIT
def __init__( self, config: Config, script: ScriptDirectory, **kw: Any ) -> None: r"""Construct a new :class:`.EnvironmentContext`. :param config: a :class:`.Config` instance. :param script: a :class:`.ScriptDirectory` instance. :param \**kw: keyword options that will be ult...
Construct a new :class:`.EnvironmentContext`. :param config: a :class:`.Config` instance. :param script: a :class:`.ScriptDirectory` instance. :param \**kw: keyword options that will be ultimately passed along to the :class:`.MigrationContext` when :meth:`.EnvironmentContext.c...
__init__
python
sqlalchemy/alembic
alembic/runtime/environment.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/environment.py
MIT
def get_starting_revision_argument(self) -> _RevNumber: """Return the 'starting revision' argument, if the revision was passed using ``start:end``. This is only meaningful in "offline" mode. Returns ``None`` if no value is available or was configured. This function does...
Return the 'starting revision' argument, if the revision was passed using ``start:end``. This is only meaningful in "offline" mode. Returns ``None`` if no value is available or was configured. This function does not require that the :class:`.MigrationContext` has been c...
get_starting_revision_argument
python
sqlalchemy/alembic
alembic/runtime/environment.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/environment.py
MIT
def get_x_argument( self, as_dictionary: bool = False ) -> Union[List[str], Dict[str, str]]: """Return the value(s) passed for the ``-x`` argument, if any. The ``-x`` argument is an open ended flag that allows any user-defined value or values to be passed on the command line, then a...
Return the value(s) passed for the ``-x`` argument, if any. The ``-x`` argument is an open ended flag that allows any user-defined value or values to be passed on the command line, then available here for consumption by a custom ``env.py`` script. The return value is a list, returned d...
get_x_argument
python
sqlalchemy/alembic
alembic/runtime/environment.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/environment.py
MIT
def run_migrations(self, **kw: Any) -> None: """Run migrations as determined by the current command line configuration as well as versioning information present (or not) in the current database connection (if one is present). The function accepts optional ``**kw`` arguments. I...
Run migrations as determined by the current command line configuration as well as versioning information present (or not) in the current database connection (if one is present). The function accepts optional ``**kw`` arguments. If these are passed, they are sent directly to th...
run_migrations
python
sqlalchemy/alembic
alembic/runtime/environment.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/environment.py
MIT
def get_context(self) -> MigrationContext: """Return the current :class:`.MigrationContext` object. If :meth:`.EnvironmentContext.configure` has not been called yet, raises an exception. """ if self._migration_context is None: raise Exception("No context has been c...
Return the current :class:`.MigrationContext` object. If :meth:`.EnvironmentContext.configure` has not been called yet, raises an exception.
get_context
python
sqlalchemy/alembic
alembic/runtime/environment.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/environment.py
MIT
def configure( cls, connection: Optional[Connection] = None, url: Optional[Union[str, URL]] = None, dialect_name: Optional[str] = None, dialect: Optional[Dialect] = None, environment_context: Optional[EnvironmentContext] = None, dialect_opts: Optional[Dict[str, st...
Create a new :class:`.MigrationContext`. This is a factory method usually called by :meth:`.EnvironmentContext.configure`. :param connection: a :class:`~sqlalchemy.engine.Connection` to use for SQL execution in "online" mode. When present, is also used to determine the type ...
configure
python
sqlalchemy/alembic
alembic/runtime/migration.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/migration.py
MIT
def get_current_revision(self) -> Optional[str]: """Return the current revision, usually that which is present in the ``alembic_version`` table in the database. This method intends to be used only for a migration stream that does not contain unmerged branches in the target database; ...
Return the current revision, usually that which is present in the ``alembic_version`` table in the database. This method intends to be used only for a migration stream that does not contain unmerged branches in the target database; if there are multiple branches present, an exception is...
get_current_revision
python
sqlalchemy/alembic
alembic/runtime/migration.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/migration.py
MIT
def get_current_heads(self) -> Tuple[str, ...]: """Return a tuple of the current 'head versions' that are represented in the target database. For a migration stream without branches, this will be a single value, synonymous with that of :meth:`.MigrationContext.get_current_revisi...
Return a tuple of the current 'head versions' that are represented in the target database. For a migration stream without branches, this will be a single value, synonymous with that of :meth:`.MigrationContext.get_current_revision`. However when multiple unmerged branches exis...
get_current_heads
python
sqlalchemy/alembic
alembic/runtime/migration.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/migration.py
MIT
def stamp(self, script_directory: ScriptDirectory, revision: str) -> None: """Stamp the version table with a specific revision. This method calculates those branches to which the given revision can apply, and updates those branches as though they were migrated towards that revision (eit...
Stamp the version table with a specific revision. This method calculates those branches to which the given revision can apply, and updates those branches as though they were migrated towards that revision (either up or down). If no current branches include the revision, it is added as ...
stamp
python
sqlalchemy/alembic
alembic/runtime/migration.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/migration.py
MIT
def run_migrations(self, **kw: Any) -> None: r"""Run the migration scripts established for this :class:`.MigrationContext`, if any. The commands in :mod:`alembic.command` will set up a function that is ultimately passed to the :class:`.MigrationContext` as the ``fn`` argument. ...
Run the migration scripts established for this :class:`.MigrationContext`, if any. The commands in :mod:`alembic.command` will set up a function that is ultimately passed to the :class:`.MigrationContext` as the ``fn`` argument. This function represents the "work" that will be ...
run_migrations
python
sqlalchemy/alembic
alembic/runtime/migration.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/migration.py
MIT
def config(self) -> Optional[Config]: """Return the :class:`.Config` used by the current environment, if any.""" if self.environment_context: return self.environment_context.config else: return None
Return the :class:`.Config` used by the current environment, if any.
config
python
sqlalchemy/alembic
alembic/runtime/migration.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/migration.py
MIT
def source_revision_ids(self) -> Tuple[str, ...]: """Active revisions before this migration step is applied.""" return ( self.down_revision_ids if self.is_upgrade else self.up_revision_ids )
Active revisions before this migration step is applied.
source_revision_ids
python
sqlalchemy/alembic
alembic/runtime/migration.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/migration.py
MIT
def destination_revision_ids(self) -> Tuple[str, ...]: """Active revisions after this migration step is applied.""" return ( self.up_revision_ids if self.is_upgrade else self.down_revision_ids )
Active revisions after this migration step is applied.
destination_revision_ids
python
sqlalchemy/alembic
alembic/runtime/migration.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/migration.py
MIT
def should_delete_branch(self, heads: Set[str]) -> bool: """A delete is when we are a. in a downgrade and b. we are going to the "base" or we are going to a version that is implied as a dependency on another version that is remaining. """ if not self.is_downgrade: re...
A delete is when we are a. in a downgrade and b. we are going to the "base" or we are going to a version that is implied as a dependency on another version that is remaining.
should_delete_branch
python
sqlalchemy/alembic
alembic/runtime/migration.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/migration.py
MIT
def from_config(cls, config: Config) -> ScriptDirectory: """Produce a new :class:`.ScriptDirectory` given a :class:`.Config` instance. The :class:`.Config` need only have the ``script_location`` key present. """ script_location = config.get_alembic_option("script_locati...
Produce a new :class:`.ScriptDirectory` given a :class:`.Config` instance. The :class:`.Config` need only have the ``script_location`` key present.
from_config
python
sqlalchemy/alembic
alembic/script/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/base.py
MIT
def walk_revisions( self, base: str = "base", head: str = "heads" ) -> Iterator[Script]: """Iterate through all revisions. :param base: the base revision, or "base" to start from the empty revision. :param head: the head revision; defaults to "heads" to indicate a...
Iterate through all revisions. :param base: the base revision, or "base" to start from the empty revision. :param head: the head revision; defaults to "heads" to indicate all head revisions. May also be "head" to indicate a single head revision.
walk_revisions
python
sqlalchemy/alembic
alembic/script/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/base.py
MIT
def get_revisions(self, id_: _GetRevArg) -> Tuple[Script, ...]: """Return the :class:`.Script` instance with the given rev identifier, symbolic name, or sequence of identifiers. """ with self._catch_revision_errors(): return cast( Tuple[Script, ...], ...
Return the :class:`.Script` instance with the given rev identifier, symbolic name, or sequence of identifiers.
get_revisions
python
sqlalchemy/alembic
alembic/script/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/base.py
MIT
def get_revision(self, id_: str) -> Script: """Return the :class:`.Script` instance with the given rev id. .. seealso:: :meth:`.ScriptDirectory.get_revisions` """ with self._catch_revision_errors(): return cast(Script, self.revision_map.get_revision(id_))
Return the :class:`.Script` instance with the given rev id. .. seealso:: :meth:`.ScriptDirectory.get_revisions`
get_revision
python
sqlalchemy/alembic
alembic/script/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/base.py
MIT
def as_revision_number( self, id_: Optional[str] ) -> Optional[Union[str, Tuple[str, ...]]]: """Convert a symbolic revision, i.e. 'head' or 'base', into an actual revision number.""" with self._catch_revision_errors(): rev, branch_name = self.revision_map._resolve_revisi...
Convert a symbolic revision, i.e. 'head' or 'base', into an actual revision number.
as_revision_number
python
sqlalchemy/alembic
alembic/script/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/base.py
MIT
def iterate_revisions( self, upper: Union[str, Tuple[str, ...], None], lower: Union[str, Tuple[str, ...], None], **kw: Any, ) -> Iterator[Script]: """Iterate through script revisions, starting at the given upper revision identifier and ending at the lower. Th...
Iterate through script revisions, starting at the given upper revision identifier and ending at the lower. The traversal uses strictly the `down_revision` marker inside each migration script, so it is a requirement that upper >= lower, else you'll get nothing back. The ...
iterate_revisions
python
sqlalchemy/alembic
alembic/script/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/base.py
MIT
def get_current_head(self) -> Optional[str]: """Return the current head revision. If the script directory has multiple heads due to branching, an error is raised; :meth:`.ScriptDirectory.get_heads` should be preferred. :return: a string revision number. .. seea...
Return the current head revision. If the script directory has multiple heads due to branching, an error is raised; :meth:`.ScriptDirectory.get_heads` should be preferred. :return: a string revision number. .. seealso:: :meth:`.ScriptDirectory.get_heads` ...
get_current_head
python
sqlalchemy/alembic
alembic/script/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/base.py
MIT
def get_base(self) -> Optional[str]: """Return the "base" revision as a string. This is the revision number of the script that has a ``down_revision`` of None. If the script directory has multiple bases, an error is raised; :meth:`.ScriptDirectory.get_bases` should be p...
Return the "base" revision as a string. This is the revision number of the script that has a ``down_revision`` of None. If the script directory has multiple bases, an error is raised; :meth:`.ScriptDirectory.get_bases` should be preferred.
get_base
python
sqlalchemy/alembic
alembic/script/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/base.py
MIT
def generate_revision( self, revid: str, message: Optional[str], head: Optional[_RevIdType] = None, splice: Optional[bool] = False, branch_labels: Optional[_RevIdType] = None, version_path: Union[str, os.PathLike[str], None] = None, file_template: Optional...
Generate a new revision file. This runs the ``script.py.mako`` template, given template arguments, and creates a new file. :param revid: String revision id. Typically this comes from ``alembic.util.rev_id()``. :param message: the revision message, the one passed by t...
generate_revision
python
sqlalchemy/alembic
alembic/script/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/base.py
MIT
def longdoc(self) -> str: """Return the docstring given in the script.""" doc = self.module.__doc__ if doc: if hasattr(self.module, "_alembic_source_encoding"): doc = doc.decode( # type: ignore[attr-defined] self.module._alembic_source_encoding ...
Return the docstring given in the script.
longdoc
python
sqlalchemy/alembic
alembic/script/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/base.py
MIT
def _revision_map(self) -> _RevisionMapType: """memoized attribute, initializes the revision map from the initial collection. """ # Ordering required for some tests to pass (but not required in # general) map_: _InterimRevisionMapType = sqlautil.OrderedDict() he...
memoized attribute, initializes the revision map from the initial collection.
_revision_map
python
sqlalchemy/alembic
alembic/script/revision.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/revision.py
MIT
def _add_depends_on( self, revisions: Collection[Revision], map_: _RevisionMapType ) -> None: """Resolve the 'dependencies' for each revision in a collection in terms of actual revision ids, as opposed to branch labels or other symbolic names. The collection is then assigned...
Resolve the 'dependencies' for each revision in a collection in terms of actual revision ids, as opposed to branch labels or other symbolic names. The collection is then assigned to the _resolved_dependencies attribute on each revision object.
_add_depends_on
python
sqlalchemy/alembic
alembic/script/revision.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/revision.py
MIT
def add_revision(self, revision: Revision, _replace: bool = False) -> None: """add a single revision to an existing map. This method is for single-revision use cases, it's not appropriate for fully populating an entire revision map. """ map_ = self._revision_map if not ...
add a single revision to an existing map. This method is for single-revision use cases, it's not appropriate for fully populating an entire revision map.
add_revision
python
sqlalchemy/alembic
alembic/script/revision.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/revision.py
MIT
def get_revisions( self, id_: Optional[_GetRevArg] ) -> Tuple[Optional[_RevisionOrBase], ...]: """Return the :class:`.Revision` instances with the given rev id or identifiers. May be given a single identifier, a sequence of identifiers, or the special symbols "head" or "base...
Return the :class:`.Revision` instances with the given rev id or identifiers. May be given a single identifier, a sequence of identifiers, or the special symbols "head" or "base". The result is a tuple of one or more identifiers, or an empty tuple in the case of "base". In the...
get_revisions
python
sqlalchemy/alembic
alembic/script/revision.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/revision.py
MIT
def get_revision(self, id_: Optional[str]) -> Optional[Revision]: """Return the :class:`.Revision` instance with the given rev id. If a symbolic name such as "head" or "base" is given, resolves the identifier into the current head or base revision. If the symbolic name refers to multip...
Return the :class:`.Revision` instance with the given rev id. If a symbolic name such as "head" or "base" is given, resolves the identifier into the current head or base revision. If the symbolic name refers to multiples, :class:`.MultipleHeads` is raised. Supports partial identifiers...
get_revision
python
sqlalchemy/alembic
alembic/script/revision.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/revision.py
MIT
def iterate_revisions( self, upper: _RevisionIdentifierType, lower: _RevisionIdentifierType, implicit_base: bool = False, inclusive: bool = False, assert_relative_length: bool = True, select_for_downgrade: bool = False, ) -> Iterator[Revision]: """Iter...
Iterate through script revisions, starting at the given upper revision identifier and ending at the lower. The traversal uses strictly the `down_revision` marker inside each migration script, so it is a requirement that upper >= lower, else you'll get nothing back. The ...
iterate_revisions
python
sqlalchemy/alembic
alembic/script/revision.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/revision.py
MIT
def _topological_sort( self, revisions: Collection[Revision], heads: Any, ) -> List[str]: """Yield revision ids of a collection of Revision objects in topological sorted order (i.e. revisions always come after their down_revisions and dependencies). Uses the order of ...
Yield revision ids of a collection of Revision objects in topological sorted order (i.e. revisions always come after their down_revisions and dependencies). Uses the order of keys in _revision_map to sort.
_topological_sort
python
sqlalchemy/alembic
alembic/script/revision.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/revision.py
MIT
def _walk( self, start: Optional[Union[str, Revision]], steps: int, branch_label: Optional[str] = None, no_overwalk: bool = True, ) -> Optional[_RevisionOrBase]: """ Walk the requested number of :steps up (steps > 0) or down (steps < 0) the revision tr...
Walk the requested number of :steps up (steps > 0) or down (steps < 0) the revision tree. :branch_label is used to select branches only when walking up. If the walk goes past the boundaries of the tree and :no_overwalk is True, None is returned, otherwise the walk terminates e...
_walk
python
sqlalchemy/alembic
alembic/script/revision.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/revision.py
MIT
def _parse_downgrade_target( self, current_revisions: _RevisionIdentifierType, target: _RevisionIdentifierType, assert_relative_length: bool, ) -> Tuple[Optional[str], Optional[_RevisionOrBase]]: """ Parse downgrade command syntax :target to retrieve the target revisi...
Parse downgrade command syntax :target to retrieve the target revision and branch label (if any) given the :current_revisions stamp of the database. Returns a tuple (branch_label, target_revision) where branch_label is a string from the command specifying the branch to consider...
_parse_downgrade_target
python
sqlalchemy/alembic
alembic/script/revision.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/revision.py
MIT
def _parse_upgrade_target( self, current_revisions: _RevisionIdentifierType, target: _RevisionIdentifierType, assert_relative_length: bool, ) -> Tuple[Optional[_RevisionOrBase], ...]: """ Parse upgrade command syntax :target to retrieve the target revision and...
Parse upgrade command syntax :target to retrieve the target revision and given the :current_revisions stamp of the database. Returns a tuple of Revision objects which should be iterated/upgraded to. The target may be specified in absolute form, or relative to :current_revisions...
_parse_upgrade_target
python
sqlalchemy/alembic
alembic/script/revision.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/revision.py
MIT
def _collect_downgrade_revisions( self, upper: _RevisionIdentifierType, lower: _RevisionIdentifierType, inclusive: bool, implicit_base: bool, assert_relative_length: bool, ) -> Tuple[Set[Revision], Tuple[Optional[_RevisionOrBase], ...]]: """ Compute th...
Compute the set of current revisions specified by :upper, and the downgrade target specified by :target. Return all dependents of target which are currently active. :inclusive=True includes the target revision in the set
_collect_downgrade_revisions
python
sqlalchemy/alembic
alembic/script/revision.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/revision.py
MIT
def _collect_upgrade_revisions( self, upper: _RevisionIdentifierType, lower: _RevisionIdentifierType, inclusive: bool, implicit_base: bool, assert_relative_length: bool, ) -> Tuple[Set[Revision], Tuple[Revision, ...]]: """ Compute the set of required r...
Compute the set of required revisions specified by :upper, and the current set of active revisions specified by :lower. Find the difference between the two to compute the required upgrades. :inclusive=True includes the current/lower revisions in the set :implicit_base=False on...
_collect_upgrade_revisions
python
sqlalchemy/alembic
alembic/script/revision.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/revision.py
MIT
def _is_real_base(self) -> bool: """Return True if this :class:`.Revision` is a "real" base revision, e.g. that it has no dependencies either.""" # we use self.dependencies here because this is called up # in initialization where _real_dependencies isn't set up # yet ret...
Return True if this :class:`.Revision` is a "real" base revision, e.g. that it has no dependencies either.
_is_real_base
python
sqlalchemy/alembic
alembic/script/revision.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/revision.py
MIT
def register(name: str) -> Callable: """A function decorator that will register that function as a write hook. See the documentation linked below for an example. .. seealso:: :ref:`post_write_hooks_custom` """ def decorate(fn): _registry[name] = fn return fn return...
A function decorator that will register that function as a write hook. See the documentation linked below for an example. .. seealso:: :ref:`post_write_hooks_custom`
register
python
sqlalchemy/alembic
alembic/script/write_hooks.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/write_hooks.py
MIT
def _invoke( name: str, revision_path: Union[str, os.PathLike[str]], options: PostWriteHookConfig, ) -> Any: """Invokes the formatter registered for the given name. :param name: The name of a formatter in the registry :param revision: string path to the revision file :param options: A dict ...
Invokes the formatter registered for the given name. :param name: The name of a formatter in the registry :param revision: string path to the revision file :param options: A dict containing kwargs passed to the specified formatter. :raises: :class:`alembic.util.CommandError`
_invoke
python
sqlalchemy/alembic
alembic/script/write_hooks.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/write_hooks.py
MIT
def _parse_cmdline_options(cmdline_options_str: str, path: str) -> List[str]: """Parse options from a string into a list. Also substitutes the revision script token with the actual filename of the revision script. If the revision script token doesn't occur in the options string, it is automaticall...
Parse options from a string into a list. Also substitutes the revision script token with the actual filename of the revision script. If the revision script token doesn't occur in the options string, it is automatically prepended.
_parse_cmdline_options
python
sqlalchemy/alembic
alembic/script/write_hooks.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/write_hooks.py
MIT
async def run_async_migrations() -> None: """In this scenario we need to create an Engine and associate a connection with the context. """ connectable = async_engine_from_config( config.get_section(config.config_ini_section, {}), prefix="sqlalchemy.", poolclass=pool.NullPool, ...
In this scenario we need to create an Engine and associate a connection with the context.
run_async_migrations
python
sqlalchemy/alembic
alembic/templates/async/env.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/templates/async/env.py
MIT
def run_migrations_online() -> None: """Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context. """ connectable = engine_from_config( config.get_section(config.config_ini_section, {}), prefix="sqlalchemy.", ...
Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context.
run_migrations_online
python
sqlalchemy/alembic
alembic/templates/generic/env.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/templates/generic/env.py
MIT
def _assert_proper_exception_context(exception): """assert that any exception we're catching does not have a __context__ without a __cause__, and that __suppress_context__ is never set. Python 3 will report nested as exceptions as "during the handling of error X, error Y occurred". That's not what we w...
assert that any exception we're catching does not have a __context__ without a __cause__, and that __suppress_context__ is never set. Python 3 will report nested as exceptions as "during the handling of error X, error Y occurred". That's not what we want to do. we want these exceptions in a cause chai...
_assert_proper_exception_context
python
sqlalchemy/alembic
alembic/testing/assertions.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/testing/assertions.py
MIT
def _no_sql_pyproject_config(dialect="postgresql", directives=""): """use a postgresql url with no host so that connections guaranteed to fail""" dir_ = _join_path(_get_staging_directory(), "scripts") return _write_toml_config( f""" [tool.alembic] script_location ="{dir_}" {textwrap.dedent(dire...
use a postgresql url with no host so that connections guaranteed to fail
_no_sql_pyproject_config
python
sqlalchemy/alembic
alembic/testing/env.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/testing/env.py
MIT
def multi_heads_fixture(cfg, a, b, c): """Create a multiple head fixture from the three-revs fixture""" # a->b->c # -> d -> e # -> f d = util.rev_id() e = util.rev_id() f = util.rev_id() script = ScriptDirectory.from_config(cfg) script.generate_revision( d, "revisio...
Create a multiple head fixture from the three-revs fixture
multi_heads_fixture
python
sqlalchemy/alembic
alembic/testing/env.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/testing/env.py
MIT
def _multidb_testing_config(engines): """alembic.ini fixture to work exactly with the 'multidb' template""" dir_ = _join_path(_get_staging_directory(), "scripts") sqlalchemy_future = "future" in config.db.__class__.__module__ databases = ", ".join(engines.keys()) engines = "\n\n".join( f"...
alembic.ini fixture to work exactly with the 'multidb' template
_multidb_testing_config
python
sqlalchemy/alembic
alembic/testing/env.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/testing/env.py
MIT
def flag_combinations(*combinations): """A facade around @testing.combinations() oriented towards boolean keyword-based arguments. Basically generates a nice looking identifier based on the keywords and also sets up the argument names. E.g.:: @testing.flag_combinations( dict(l...
A facade around @testing.combinations() oriented towards boolean keyword-based arguments. Basically generates a nice looking identifier based on the keywords and also sets up the argument names. E.g.:: @testing.flag_combinations( dict(lazy=False, passive=False), dict(l...
flag_combinations
python
sqlalchemy/alembic
alembic/testing/util.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/testing/util.py
MIT
def resolve_lambda(__fn, **kw): """Given a no-arg lambda and a namespace, return a new lambda that has all the values filled in. This is used so that we can have module-level fixtures that refer to instance-level variables using lambdas. """ pos_args = inspect_getfullargspec(__fn)[0] pass...
Given a no-arg lambda and a namespace, return a new lambda that has all the values filled in. This is used so that we can have module-level fixtures that refer to instance-level variables using lambdas.
resolve_lambda
python
sqlalchemy/alembic
alembic/testing/util.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/testing/util.py
MIT
def setup_filters(): """Set global warning behavior for the test suite.""" warnings.resetwarnings() warnings.filterwarnings("error", category=sa_exc.SADeprecationWarning) warnings.filterwarnings("error", category=sa_exc.SAWarning) # some selected deprecations... warnings.filterwarnings("error...
Set global warning behavior for the test suite.
setup_filters
python
sqlalchemy/alembic
alembic/testing/warnings.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/testing/warnings.py
MIT
def test_nochange_ondelete_restrict(self): """test the RESTRICT option which MySQL doesn't report on""" diffs = self._fk_opts_fixture( {"ondelete": "restrict"}, {"ondelete": "restrict"} ) eq_(diffs, [])
test the RESTRICT option which MySQL doesn't report on
test_nochange_ondelete_restrict
python
sqlalchemy/alembic
alembic/testing/suite/test_autogen_fks.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/testing/suite/test_autogen_fks.py
MIT
def test_nochange_ondelete_noaction(self): """test the NO ACTION option which generally comes back as None""" diffs = self._fk_opts_fixture( {"ondelete": "no action"}, {"ondelete": "no action"} ) eq_(diffs, [])
test the NO ACTION option which generally comes back as None
test_nochange_ondelete_noaction
python
sqlalchemy/alembic
alembic/testing/suite/test_autogen_fks.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/testing/suite/test_autogen_fks.py
MIT
def path_relative_to( path: Path, other: Path, *, walk_up: bool = False ) -> Path: """ Calculate the relative path of 'path' with respect to 'other', optionally allowing 'path' to be outside the subtree of 'other'. OK I used AI for this, sorry """ try: ...
Calculate the relative path of 'path' with respect to 'other', optionally allowing 'path' to be outside the subtree of 'other'. OK I used AI for this, sorry
path_relative_to
python
sqlalchemy/alembic
alembic/util/compat.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/util/compat.py
MIT
def open_in_editor( filename: str, environ: Optional[Dict[str, str]] = None ) -> None: """ Opens the given file in a text editor. If the environment variable ``EDITOR`` is set, this is taken as preference. Otherwise, a list of commonly installed editors is tried. If no editor matches, an :py:e...
Opens the given file in a text editor. If the environment variable ``EDITOR`` is set, this is taken as preference. Otherwise, a list of commonly installed editors is tried. If no editor matches, an :py:exc:`OSError` is raised. :param filename: The filename to open. Will be passed verbatim to th...
open_in_editor
python
sqlalchemy/alembic
alembic/util/editor.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/util/editor.py
MIT
def branch(self) -> Dispatcher: """Return a copy of this dispatcher that is independently writable.""" d = Dispatcher() if self.uselist: d._registry.update( (k, [fn for fn in self._registry[k]]) for k in self._registry ) else: ...
Return a copy of this dispatcher that is independently writable.
branch
python
sqlalchemy/alembic
alembic/util/langhelpers.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/util/langhelpers.py
MIT
def coerce_resource_to_filename(fname_or_resource: str) -> pathlib.Path: """Interpret a filename as either a filesystem location or as a package resource. Names that are non absolute paths and contain a colon are interpreted as resources and coerced to a file location. """ # TODO: there seem t...
Interpret a filename as either a filesystem location or as a package resource. Names that are non absolute paths and contain a colon are interpreted as resources and coerced to a file location.
coerce_resource_to_filename
python
sqlalchemy/alembic
alembic/util/pyfiles.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/util/pyfiles.py
MIT
def pyc_file_from_path( path: Union[str, os.PathLike[str]], ) -> Optional[pathlib.Path]: """Given a python source path, locate the .pyc.""" pathpath = pathlib.Path(path) candidate = pathlib.Path( importlib.util.cache_from_source(pathpath.as_posix()) ) if candidate.exists(): retu...
Given a python source path, locate the .pyc.
pyc_file_from_path
python
sqlalchemy/alembic
alembic/util/pyfiles.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/util/pyfiles.py
MIT
def load_python_file( dir_: Union[str, os.PathLike[str]], filename: Union[str, os.PathLike[str]] ) -> ModuleType: """Load a file from the given path as a Python module.""" dir_ = pathlib.Path(dir_) filename_as_path = pathlib.Path(filename) filename = filename_as_path.name module_id = re.sub(r"...
Load a file from the given path as a Python module.
load_python_file
python
sqlalchemy/alembic
alembic/util/pyfiles.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/util/pyfiles.py
MIT
def _preserving_path_as_str(path: Union[str, os.PathLike[str]]) -> str: """receive str/pathlike and return a string. Does not convert an incoming string path to a Path first, to help with unit tests that are doing string path round trips without OS-specific processing if not necessary. """ if ...
receive str/pathlike and return a string. Does not convert an incoming string path to a Path first, to help with unit tests that are doing string path round trips without OS-specific processing if not necessary.
_preserving_path_as_str
python
sqlalchemy/alembic
alembic/util/pyfiles.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/util/pyfiles.py
MIT
def _find_columns(clause): """locate Column objects within the given expression.""" cols: Set[ColumnElement[Any]] = set() traverse(clause, {}, {"column": cols.add}) return cols
locate Column objects within the given expression.
_find_columns
python
sqlalchemy/alembic
alembic/util/sqla_compat.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/util/sqla_compat.py
MIT