diff options
author | James Addison <james@reciperadar.com> | 2023-04-10 15:40:38 -0400 |
---|---|---|
committer | Federico Caselli <cfederico87@gmail.com> | 2023-04-12 22:36:39 +0200 |
commit | d3f869bb3159d18669fb6f00cbe514307118eea7 (patch) | |
tree | 32b83d276b3eaf779dcea37aa1c59e0b0da5e596 /alembic/context.pyi | |
parent | 33a9947686a7c8bb3becd6169ec7abe84cf2c7e6 (diff) | |
download | alembic-d3f869bb3159d18669fb6f00cbe514307118eea7.tar.gz |
tooling: write_pyi.py: filter usage of raw-strings (rstrings)
### Description
While reading the diff between [`rel_1_10_2...rel_1_10_3`](https://github.com/sqlalchemy/alembic/compare/rel_1_10_2...rel_1_10_3), the introduction of r-strings drew my attention, and that resulted in some [discussion on the relevant commit](https://github.com/sqlalchemy/alembic/commit/bc0c305b7c2cc0401e250fcd6a725aacecdd6e33).
This changeset filters the production of r-strings during stub-generation to cases where docstrings contain escape (backslash, `\`) characters.
I'll admit that I didn't realize until today that these stubs are primarily for typechecking. Since that's the case, I have doubts about whether the change is worthwhile (consistency and simplicity -- using r-strings for all docstrings in the stubs -- even if it's redundant, seems fine to me).
### Checklist
This pull request is:
- [x] A documentation / typographical error fix
- [x] A short code fix
- Relates to discussion at https://github.com/sqlalchemy/alembic/commit/bc0c305b7c2cc0401e250fcd6a725aacecdd6e33
Closes: #1218
Pull-request: https://github.com/sqlalchemy/alembic/pull/1218
Pull-request-sha: 352ab8829525435f78838687e12156a3fa3a3d86
Closes: #1219
Pull-request: https://github.com/sqlalchemy/alembic/pull/1219
Change-Id: I2808a592681dabc093d538f589e673fcc5e05822
Diffstat (limited to 'alembic/context.pyi')
-rw-r--r-- | alembic/context.pyi | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/alembic/context.pyi b/alembic/context.pyi index a262638..a9f48b2 100644 --- a/alembic/context.pyi +++ b/alembic/context.pyi @@ -29,7 +29,7 @@ if TYPE_CHECKING: ### end imports ### def begin_transaction() -> Union[_ProxyTransaction, ContextManager[None]]: - r"""Return a context manager that will + """Return a context manager that will enclose an operation within a "transaction", as defined by the environment's offline and transactional DDL settings. @@ -107,7 +107,7 @@ def configure( on_version_apply: Optional[Callable[..., None]] = None, **kw: Any, ) -> None: - r"""Configure a :class:`.MigrationContext` within this + """Configure a :class:`.MigrationContext` within this :class:`.EnvironmentContext` which will provide database connectivity and other configuration to a series of migration scripts. @@ -543,7 +543,7 @@ def configure( def execute( sql: Union[ClauseElement, str], execution_options: Optional[dict] = None ) -> None: - r"""Execute the given SQL using the current change context. + """Execute the given SQL using the current change context. The behavior of :meth:`.execute` is the same as that of :meth:`.Operations.execute`. Please see that @@ -556,7 +556,7 @@ def execute( """ def get_bind() -> Connection: - r"""Return the current 'bind'. + """Return the current 'bind'. In "online" mode, this is the :class:`sqlalchemy.engine.Connection` currently being used @@ -568,7 +568,7 @@ def get_bind() -> Connection: """ def get_context() -> MigrationContext: - r"""Return the current :class:`.MigrationContext` object. + """Return the current :class:`.MigrationContext` object. If :meth:`.EnvironmentContext.configure` has not been called yet, raises an exception. @@ -576,7 +576,7 @@ def get_context() -> MigrationContext: """ def get_head_revision() -> Union[str, Tuple[str, ...], None]: - r"""Return the hex identifier of the 'head' script revision. + """Return the hex identifier of the 'head' script revision. If the script directory has multiple heads, this method raises a :class:`.CommandError`; @@ -590,7 +590,7 @@ def get_head_revision() -> Union[str, Tuple[str, ...], None]: """ def get_head_revisions() -> Union[str, Tuple[str, ...], None]: - r"""Return the hex identifier of the 'heads' script revision(s). + """Return the hex identifier of the 'heads' script revision(s). This returns a tuple containing the version number of all heads in the script directory. @@ -601,7 +601,7 @@ def get_head_revisions() -> Union[str, Tuple[str, ...], None]: """ def get_revision_argument() -> Union[str, Tuple[str, ...], None]: - r"""Get the 'destination' revision argument. + """Get the 'destination' revision argument. This is typically the argument passed to the ``upgrade`` or ``downgrade`` command. @@ -616,7 +616,7 @@ def get_revision_argument() -> Union[str, Tuple[str, ...], None]: """ def get_starting_revision_argument() -> Union[str, Tuple[str, ...], None]: - r"""Return the 'starting revision' argument, + """Return the 'starting revision' argument, if the revision was passed using ``start:end``. This is only meaningful in "offline" mode. @@ -629,7 +629,7 @@ def get_starting_revision_argument() -> Union[str, Tuple[str, ...], None]: """ def get_tag_argument() -> Optional[str]: - r"""Return the value passed for the ``--tag`` argument, if any. + """Return the value passed for the ``--tag`` argument, if any. The ``--tag`` argument is not used directly by Alembic, but is available for custom ``env.py`` configurations that @@ -655,7 +655,7 @@ def get_x_argument(as_dictionary: Literal[True]) -> Dict[str, str]: ... def get_x_argument( as_dictionary: bool = ..., ) -> Union[List[str], Dict[str, str]]: - r"""Return the value(s) passed for the ``-x`` argument, if any. + """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 @@ -695,7 +695,7 @@ def get_x_argument( """ def is_offline_mode() -> bool: - r"""Return True if the current migrations environment + """Return True if the current migrations environment is running in "offline mode". This is ``True`` or ``False`` depending @@ -707,7 +707,7 @@ def is_offline_mode() -> bool: """ def is_transactional_ddl(): - r"""Return True if the context is configured to expect a + """Return True if the context is configured to expect a transactional DDL capable backend. This defaults to the type of database in use, and @@ -720,7 +720,7 @@ def is_transactional_ddl(): """ def run_migrations(**kw: Any) -> None: - r"""Run migrations as determined by the current command line + """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). @@ -743,7 +743,7 @@ def run_migrations(**kw: Any) -> None: script: ScriptDirectory def static_output(text: str) -> None: - r"""Emit text directly to the "offline" SQL stream. + """Emit text directly to the "offline" SQL stream. Typically this is for emitting comments that start with --. The statement is not treated |