Skip to content

fix: refactor code for codacy#446

Merged
DylanWelzel merged 4 commits into
1.1.xfrom
codacy-fixes
May 26, 2026
Merged

fix: refactor code for codacy#446
DylanWelzel merged 4 commits into
1.1.xfrom
codacy-fixes

Conversation

@DylanWelzel

Copy link
Copy Markdown
Contributor

This pull request refactors how configuration and module imports are handled throughout the BioThings CLI codebase. The main improvement is the introduction of a new get_biothings_config helper function, which standardizes and centralizes the way the configuration module is accessed. Additionally, dynamic imports are now used in several places to delay importing modules and attributes until they are needed, improving modularity and potentially reducing import-time errors. Minor code style and error handling improvements are also included.

Configuration and Import Handling Improvements:

  • Introduced a new get_biothings_config function in decorators.py to standardize access to the biothings.config module, replacing direct imports in multiple files and functions. [1] [2] [3] [4] [5]
  • Replaced direct imports of configuration and other modules in operations.py with calls to get_biothings_config and dynamic imports via a new _load_attr helper, improving modularity and reducing upfront dependencies. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]

Code Style and Error Handling:

  • Improved error handling in get_code_for_mod_name by chaining exceptions for clearer tracebacks.
  • Simplified and clarified multi-line string assignments and dedentation in dynamic class generation code, reducing unnecessary parentheses and improving readability. [1] [2] [3] [4]
  • Added pylint disables for functions with many arguments to suppress linter warnings where appropriate. [1] [2]

Dependency and Import Cleanup:

  • Moved some imports to the top of files and removed unnecessary duplicate imports in mongo_build_cleanup.py, improving clarity and reducing redundancy. [1] [2] [3] [4]

These changes collectively improve the maintainability and robustness of the CLI codebase by centralizing configuration access, reducing tight coupling between modules, and enhancing error reporting.

@DylanWelzel
DylanWelzel merged commit 5a30fdf into 1.1.x May 26, 2026
13 checks passed
@DylanWelzel
DylanWelzel deleted the codacy-fixes branch May 26, 2026 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant