From db65d404a5fe9fc2075b5eed3f12dbde9f1841bd Mon Sep 17 00:00:00 2001 From: John Rouillard Date: Sat, 4 Jan 2025 20:50:59 -0500 Subject: [PATCH] chore(ruff): var name changes; unused import; formatting Handle vars variable hiding builting vars(). Use more descripting variable name. Remove unused sys import. Add double lines where needed. --- roundup/backends/__init__.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/roundup/backends/__init__.py b/roundup/backends/__init__.py index d29b2835..9d50d284 100644 --- a/roundup/backends/__init__.py +++ b/roundup/backends/__init__.py @@ -19,8 +19,6 @@ ''' __docformat__ = 'restructuredtext' -import sys - # These names are used to suppress import errors. # If get_backend raises an ImportError with appropriate # module name, have_backend quietly returns False. @@ -31,18 +29,20 @@ 'sqlite': ('sqlite3', '_sqlite3'), } + def get_backend(name): '''Get a specific backend by name.''' - vars = globals() + global_vars = globals() # if requested backend has been imported yet, return current instance - if name in vars: - return vars[name] + if name in global_vars: + return global_vars[name] # import the backend module module_name = 'back_%s' % name - module = __import__(module_name, vars, level=1) - vars[name] = module + module = __import__(module_name, global_vars, level=1) + global_vars[name] = module return module + def have_backend(name): '''Is backend "name" available?''' try: @@ -62,6 +62,7 @@ def have_backend(name): raise return 0 + def list_backends(): '''List all available backend names. @@ -75,10 +76,10 @@ def list_backends(): because we do not need to monkey-patch list_backends. ''' - l = [] + backend_list = [] for name in 'anydbm', 'mysql', 'sqlite', 'postgresql', 'memorydb': if have_backend(name): - l.append(name) - return l + backend_list.append(name) + return backend_list # vim: set filetype=python sts=4 sw=4 et si :