From 9ea53878c9a4f23510d5db02111c5b6caf24d6af Mon Sep 17 00:00:00 2001 From: Michael Hanke Date: Tue, 17 Sep 2024 14:14:28 +0200 Subject: [PATCH 1/3] fix: delay import to have import subject be impacted by patches --- datalad_next/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/datalad_next/__init__.py b/datalad_next/__init__.py index f50fa2db..66872cc0 100644 --- a/datalad_next/__init__.py +++ b/datalad_next/__init__.py @@ -53,13 +53,14 @@ # patch datalad-core import datalad_next.patches.enabled - -# register additional configuration items in datalad-core -from datalad.support.extensions import register_config from datalad_next.constraints import ( EnsureBool, EnsureChoice, ) + +# register additional configuration items in datalad-core +from datalad.support.extensions import register_config + register_config( 'datalad.credentials.repeat-secret-entry', 'Require entering secrets twice for interactive specification?', From adab6aa01b05765efbd8df830d4ede6f1b5f4584 Mon Sep 17 00:00:00 2001 From: Michael Hanke Date: Wed, 25 Sep 2024 11:25:04 +0200 Subject: [PATCH 2/3] fix: proper import of version information to the top-level module --- datalad_next/__init__.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/datalad_next/__init__.py b/datalad_next/__init__.py index 66872cc0..ee5b6190 100644 --- a/datalad_next/__init__.py +++ b/datalad_next/__init__.py @@ -2,6 +2,8 @@ __docformat__ = 'restructuredtext' +from datalad_next._version import __version__ + import logging lgr = logging.getLogger('datalad.next') @@ -108,9 +110,3 @@ default=False, dialog='yesno', ) - - -try: - from ._version import version as __version__ -except ImportError: - pass From ec0f041c389f5a4ec8f9dae406b16030822b965f Mon Sep 17 00:00:00 2001 From: Michael Hanke Date: Wed, 25 Sep 2024 11:40:48 +0200 Subject: [PATCH 3/3] style: ruff top-level `__init__.py` --- datalad_next/__init__.py | 53 ++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/datalad_next/__init__.py b/datalad_next/__init__.py index ee5b6190..92fc000b 100644 --- a/datalad_next/__init__.py +++ b/datalad_next/__init__.py @@ -2,9 +2,21 @@ __docformat__ = 'restructuredtext' -from datalad_next._version import __version__ +__all__ = [ + '__version__', + 'command_suite', + # TODO: REMOVE FOR V2.0 + 'lgr', +] import logging + +from datalad_next._version import __version__ + +# patch datalad-core +from datalad_next.patches import enabled as enabled # noqa: PLC0414 + +# TODO: REMOVE FOR V2.0 lgr = logging.getLogger('datalad.next') # Defines a datalad command suite. @@ -12,7 +24,7 @@ # to be found by datalad command_suite = ( # description of the command suite, displayed in cmdline help - "What is next in DataLad", + 'What is next in DataLad', [ # specification of a command, any number of commands can be defined ( @@ -36,52 +48,57 @@ # name of the command class implementation in above module 'TreeCommand', # command name (differs from lowercase command class name) - 'tree' + 'tree', ), ( - 'datalad_next.commands.download', 'Download', 'download', + 'datalad_next.commands.download', + 'Download', + 'download', ), ( - 'datalad_next.commands.ls_file_collection', 'LsFileCollection', + 'datalad_next.commands.ls_file_collection', + 'LsFileCollection', 'ls-file-collection', ), ( - 'datalad_next.commands.status', 'Status', - 'next-status', 'next_status', + 'datalad_next.commands.status', + 'Status', + 'next-status', + 'next_status', ), - ] + ], ) -# patch datalad-core -import datalad_next.patches.enabled -from datalad_next.constraints import ( +# register additional configuration items in datalad-core +from datalad.support.extensions import register_config # noqa: E402 + +from datalad_next.constraints import ( # noqa: E402 EnsureBool, EnsureChoice, ) -# register additional configuration items in datalad-core -from datalad.support.extensions import register_config - register_config( 'datalad.credentials.repeat-secret-entry', 'Require entering secrets twice for interactive specification?', type=EnsureBool(), default=True, - dialog='yesno') + dialog='yesno', +) register_config( 'datalad.credentials.hidden-secret-entry', 'Hide secret in interactive entry?', type=EnsureBool(), default=True, - dialog='yesno') + dialog='yesno', +) register_config( 'datalad.clone.url-substitute.webdav', 'webdav(s):// clone URL substitution', - description="Convenience conversion of custom WebDAV URLs to " + description='Convenience conversion of custom WebDAV URLs to ' "git-cloneable 'datalad-annex::'-type URLs. The 'webdav://' " "prefix implies a remote sibling in 'filetree' or 'export' mode " - "See https://docs.datalad.org/design/url_substitution.html for details", + 'See https://docs.datalad.org/design/url_substitution.html for details', dialog='question', scope='global', default=(