Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate and remove usage of aiida.common.utils.strip_prefix #6705

Open
danielhollas opened this issue Jan 14, 2025 · 2 comments
Open

Deprecate and remove usage of aiida.common.utils.strip_prefix #6705

danielhollas opened this issue Jan 14, 2025 · 2 comments
Labels
good first issue Issues that should be relatively easy to fix also for beginning contributors help wanted type/feature request status undecided

Comments

@danielhollas
Copy link
Collaborator

Since Python 3.9 this is now equivalent to the str.removeprefix builtin: https://docs.python.org/3.9/library/stdtypes.html#str.removeprefix

rg strip_prefix
src/aiida/common/utils.py
450:def strip_prefix(full_string: str, prefix: str):

src/aiida/orm/utils/node.py
15:from aiida.common.utils import strip_prefix
52:        base_path = strip_prefix(base_path, 'node.')
57:        entry_point_name = strip_prefix(base_path, 'data.')
64:        entry_point_name = strip_prefix(base_path, 'nodes.')
102:        type_string = strip_prefix(type_string, prefix)

src/aiida/restapi/common/identifiers.py
138:    from aiida.common.utils import strip_prefix
154:        base_name = strip_prefix(node_type, data_prefix)
232:        from aiida.common.utils import strip_prefix
237:        full_type = strip_prefix(self._path, 'node.')
242:                    plugin_name = strip_prefix(full_type, basepath)
245:                        plugin_name = strip_prefix(plugin_name, DEFAULT_NAMESPACE_LABEL + '.')
@danielhollas danielhollas added help wanted good first issue Issues that should be relatively easy to fix also for beginning contributors type/feature request status undecided labels Jan 14, 2025
@danielhollas
Copy link
Collaborator Author

Similarly, I think we can just remove the aiida.common.utils.ArrayCounter. It is not used anywhere, and it's docstring specifically says that it is used in various tests, so I guess we don't need to treat as a stable API?

@danielhollas
Copy link
Collaborator Author

danielhollas commented Jan 14, 2025

Since the symbols from aiida.common.utils are not exported at the top level aiida.common I guess it's fine to remove / move stuff. We should just audit this file as a whole, there are a bunch of weird and reaaally specific functions / classes that do not seem general enough to warrant being in this module. For example, functions join_labels and prettify_labels (and the associated Prettifier class) are used only used only in src/aiida/orm/nodes/data/array/bands.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issues that should be relatively easy to fix also for beginning contributors help wanted type/feature request status undecided
Projects
None yet
Development

No branches or pull requests

1 participant