]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
more tweaks
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 21 May 2025 03:40:33 +0000 (23:40 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 21 May 2025 03:40:33 +0000 (23:40 -0400)
this is primarily cleanup of the changelog section which is
extensive for this release.

Additionally, limited Config.config_file_name and Config.toml_file_name
to string only when accessed, making use of _preserving_path_as_str()
for these on the parameter side.

Change-Id: I9bec7bdc7fcaa79efeccb5e6f584be3f328499f2

alembic/config.py
docs/build/_static/site_custom_css.css
docs/build/conf.py
docs/build/unreleased/1082.rst
docs/build/unreleased/1330.rst
docs/build/unreleased/1610.rst
docs/build/unreleased/1626.rst
docs/build/unreleased/1637.rst
docs/build/unreleased/1650.rst
docs/build/unreleased/1656.rst
docs/build/unreleased/pathlib.rst

index c63f0aeda7496d0190c4cf63a15c5ab1b73df8b7..eb98bcdf9f864c52ca3040fa278e07b63dc22531 100644 (file)
@@ -25,6 +25,7 @@ from . import __version__
 from . import command
 from . import util
 from .util import compat
+from .util.pyfiles import _preserving_path_as_str
 
 
 class Config:
@@ -113,8 +114,12 @@ class Config:
         attributes: Optional[Dict[str, Any]] = None,
     ) -> None:
         """Construct a new :class:`.Config`"""
-        self.config_file_name = file_
-        self.toml_file_name = toml_file
+        self.config_file_name = (
+            _preserving_path_as_str(file_) if file_ else None
+        )
+        self.toml_file_name = (
+            _preserving_path_as_str(toml_file) if toml_file else None
+        )
         self.config_ini_section = ini_section
         self.output_buffer = output_buffer
         self.stdout = stdout
@@ -136,10 +141,10 @@ class Config:
 
     """
 
-    config_file_name: Union[str, os.PathLike[str], None] = None
+    config_file_name: Optional[str] = None
     """Filesystem path to the .ini file in use."""
 
-    toml_file_name: Union[str, os.PathLike[str], None] = None
+    toml_file_name: Optional[str] = None
     """Filesystem path to the pyproject.toml file in use.
 
     .. versionadded:: 1.16.0
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..8194030b79e0ef94bed9beba44e38991fb7c9265 100644 (file)
@@ -0,0 +1,3 @@
+ul.simple p {
+    margin-bottom: 1.15rem;
+}
\ No newline at end of file
index 8b4030721a6087a991be5911d1af6867ed790f28..c8c9e76313ee9e104110017a198e3cb5e4a4a9f9 100644 (file)
@@ -57,6 +57,7 @@ changelog_sections = [
     "feature",
     "usecase",
     "bug",
+    "refactored",
     "moved",
     "removed",
 ]
index 8b58c5e8da48ca467206a6333023fd1bba3e92bd..244f3e8f518ee3ccede512823bb108578b40d420 100644 (file)
@@ -2,18 +2,30 @@
     :tags: feature, environment
     :tickets: 1082
 
-    Added optional :pep:`621` support to Alembic, where a subset of the
-    project-centric configuration normally found in the ``alembic.ini`` file
-    can now be retrieved from the project-wide ``pyproject.toml`` file.   A new
-    init template ``pyproject`` is added which illustrates a basic :pep:`621`
-    setup.  The :pep:`621` feature supports configuration values that are
-    relevant to code locations and code production only; it does not
-    accommodate database connectivity, configuration, or logging configuration.
-    These latter configurational elements remain as elements that can be
-    present either in the ``alembic.ini`` file, or retrieved elsewhere within
-    the ``env.py`` file.   The change also allows the ``alembic.ini`` file to
-    be completely optional if the ``pyproject.toml`` file contains a base
-    alembic configuration section.
+    Added optional :pep:`621` support to Alembic, allowing all source code
+    related configuration (e.g. local file paths, post write hook
+    configurations, etc) to be configured in the project's ``pyproject.toml``
+    file.   A new init template ``pyproject`` is added which illustrates a
+    basic :pep:`621` setup.
+
+    Besides being better integrated with a Python project's existing source
+    code configuration, the TOML format allows for more flexible structures,
+    allowing configuration items like ``version_locations`` and
+    ``prepend_sys_path`` to be configured as lists of path strings without the
+    need for path separator characters used by ``ConfigParser`` format.   The
+    feature continues to support the ``%(here)s`` token which can substitute
+    the absolute parent directory of the ``pyproject.toml`` file when
+    consumed.
+
+    The :pep:`621` feature supports configuration values that are relevant to
+    source code organization and generation only; it does not accommodate
+    configuration of database connectivity or logging, which remain under the
+    category of "deployment" configuration and continue to be part of
+    ``alembic.ini``, or whatever configurational method is established by the
+    ``env.py`` file.   Using the combination of ``pyproject.toml`` for source
+    code configuration along with a custom database/logging configuration
+    method established in ``env.py`` will allow the ``alembic.ini`` file to be
+    omitted altogether.
 
 
     .. seealso::
index 736149fdf4df7891848497d8c808732281ee723b..c426b0fae611338dbea8261e3a344435ca1ce285 100644 (file)
@@ -1,28 +1,29 @@
 .. change::
-    :tags: bug, environment
+    :tags: usecase, environment
     :tickets: 1330
 
-    Added new option to the ConfigParser config (typically via ``alembic.ini``)
-    ``path_separator``. This new option supersedes the previous similar
-    option ``version_path_separator``.   The new ``path_separator`` option
-    applies to the path splitting mechanism of both the ``version_locations``
-    option as well as the ``prepend_sys_path`` option, and in newly
-    rendered ``alembic.ini`` files will use the value ``os``, which means to
-    use the operating system path separator when splitting these string values
-    into a list of paths.
+    Added new option to the ConfigParser (e.g. ``alembic.ini``) configuration
+    ``path_separator``, which supersedes the existing ``version_path_separator``
+    option.  ``path_separator`` specifies the path separator character that
+    will be recognized for both the ``version_locations`` option as well
+    as the ``prepend_sys_path`` option, defaulting to ``os`` which indicates
+    that the value of ``os.pathsep`` should be used.
 
     The new attribute applies necessary os-dependent path splitting to the
     ``prepend_sys_path`` option so that windows paths which contain drive
     letters with colons are not inadvertently split, whereas previously
-    os-dependent path splitting were only available for the
-    ``version_locations`` option.
+    os-dependent path splitting were only available for the ``version_locations`` option.
 
-    Existing installations that do not have ``path_separator`` present
-    will continue to make use of ``version_path_separator`` when parsing the
-    ``version_locations`` option, or splitting on spaces / commas if
-    ``version_path_separator`` is also not present.  ``prepend_sys_path`` will
-    continue to be split on spaces/commas/colons if ``path_separator`` is
-    not present.   Under all of these fallback conditions, a deprecation
-    warning is now emitted encouraging to set ``path_separator``.
+    Existing installations that don't indicate ``path_separator``
+    will continue to use the older behavior, where ``version_path_separator``
+    may be configured for ``version_locations``, and ``prepend_sys_path``
+    continues to be split on spaces/commas/colons.  A deprecation warning
+    is emitted for these fallback scenarios.
+
+    When using the new ``pyproject.toml`` configuration detailed at
+    :ref:`using_pep_621`, the whole issue of "path separators" is sidestepped
+    and parameters like ``path_separator`` are unnecessary, as the TOML based
+    configuration configures version locations and sys path elements as
+    lists.
 
     Pull request courtesy Mike Werezak.
\ No newline at end of file
index b6f37d0928c6fe7bd5852bd194fd38bed6975593..73e0fe164b44d37553bb49ffd246066c22d42660 100644 (file)
@@ -1,5 +1,5 @@
 .. change::
-    :tags: usecase, commands
+    :tags: feature, commands
     :tickets: 1610
 
     Added new :meth:`.CommandLine.register_command` method to
index 664e195876c988e1af289de41cb58dbcee0ec85a..6bb0e9e2e4371bf1e857fcb979c7241cf83d273e 100644 (file)
@@ -1,5 +1,5 @@
 .. change::
-    :tags: usecase, autogenerate, postgresql
+    :tags: usecase, operations
     :tickets: 1626
 
     Added :paramref:`.Operations.add_column.if_not_exists` and
@@ -7,5 +7,5 @@
     for ``ADD COLUMN`` and ``DROP COLUMN`` operations, a feature available on
     some database backends such as PostgreSQL, MariaDB, as well as third party
     backends.  The parameters also support autogenerate rendering allowing them
-    to be turned on via a custom :class:`.Rewriter`. Pull request courtesy of
-    Louis-Amaury Chaib (@lachaib).
\ No newline at end of file
+    to be added to autogenerate scripts via a custom :class:`.Rewriter`.  Pull
+    request courtesy of Louis-Amaury Chaib (@lachaib).
\ No newline at end of file
index 08ddf60b175d50bc8748d9ffb178ddc5213d679f..059a59a4ef2d37bee9f932f709f949af2abaf7bc 100644 (file)
@@ -2,7 +2,8 @@
     :tags: bug, general
     :tickets: 1637
 
-    The pyproject.toml configuration has been amended to use the updated
-    :pep:`639` configuration for license, which eliminates loud deprecation
-    warnings when building the package.   Note this necessarily bumps
-    setuptools build requirement to 77.0.3.
+    The ``pyproject.toml`` file used by the Alembic project itself for its
+    Python package configuration has been amended to use the updated :pep:`639`
+    configuration for license, which eliminates loud deprecation warnings when
+    building the package.   Note this necessarily bumps setuptools build
+    requirement to 77.0.3.
index 7e1bc379aa5f6186343509d3638114040723db79..29ac2de05c71c1ca83f88f18b0950fbcef204154 100644 (file)
@@ -3,7 +3,7 @@
     :tickets: 1650
 
     Added :paramref:`.Operations.drop_constraint.if_exists` parameter to
-    :meth:`.Operations.drop_constraint` which will render "DROP CONSTRAINT IF
-    EXISTS". The parameter also supports autogenerate rendering allowing them
-    to be turned on via a custom :class:`.Rewriter`.  Pull request courtesy
-    Aaron Griffin.
+    :meth:`.Operations.drop_constraint` which will render ``DROP CONSTRAINT IF
+    EXISTS``. The parameter also supports autogenerate rendering allowing it to
+    be added to autogenerate scripts via a custom :class:`.Rewriter`.  Pull
+    request courtesy Aaron Griffin.
index 3680aa72aa523c2b7b5bc981d15e568cc51860cf..040a3848899fb3a72674c92ef448dde8500865ac 100644 (file)
@@ -1,8 +1,10 @@
 .. change::
-    :tags: bug, operations
+    :tags: bug, autogenerate
     :tickets: 1656
 
-    The ExecuteSQLOp now takes into account the value configured
-    in :paramref:`configure.alembic_module_prefix` instead of always
-    defaulting to ``op.``.
-    Pull request curtesy of Avery Fischer.
+    The :meth:`.Operations.execute` operation when rendered in autogenerate
+    (which would necessarily be only when using a custom writer that embeds
+    :class:`.ExecuteSQLOp`) now correctly takes into account the value
+    configured in :paramref:`configure.alembic_module_prefix` when rendering
+    the operation with its prefixing namespace; previously this was hardcoded
+    to ``op.``. Pull request courtesy Avery Fischer.
index 1c547b85bf612903cd34827141e5c8ad622e02c2..dc29a988c5b6b6a8f88b84dbea3e66990e1da534 100644 (file)
@@ -1,11 +1,16 @@
 .. change::
-    :tags: change, environment
+    :tags: refactored, environment
 
     The command, config and script modules now rely on ``pathlib.Path`` for
-    internal path manipulations, instead of ``os.path()`` operations.   Public
-    API functions that accept string directories and filenames continue to do
-    so but also accept ``os.PathLike`` objects.  Public API functions and
-    accessors that return paths as strings continue to do so.   Private API
-    functions and accessors, i.e. all those that are prefixed with an
-    underscore, may now return a Path object rather than a string to indicate
-    file paths.
+    internal path manipulations, instead of ``os.path()`` operations.   This
+    has some impact on both public and private (i.e. underscored) API functions:
+
+    * Public API functions that accept parameters indicating file and directory
+      paths as strings will continue to do so, but now will also accept
+      ``os.PathLike`` objects as well.
+    * Public API functions and accessors that return directory paths as strings
+      such as :attr:`.ScriptDirectory.dir`, :attr:`.Config.config_file_name`
+      will continue to do so.
+    * Private API functions and accessors, i.e. all those that are prefixed
+      with an underscore, that previously returned directory paths as
+      strings may now return a Path object instead.