From 4c8696aa8232c5634366996a52ba1683eedcc052 Mon Sep 17 00:00:00 2001
From: "Peter J. A. Cock"
Date: Wed, 15 Oct 2025 11:37:00 +0100
Subject: [PATCH] Remove unused or read only globals (flake8 F824)
---
Bio/TogoWS/__init__.py | 2 +-
BioSQL/BioSeqDatabase.py | 4 +---
Tests/common_BioSQL.py | 3 +--
Tests/common_BioSQL_online.py | 6 ++----
Tests/run_tests.py | 1 -
Tests/test_Tutorial.py | 2 --
6 files changed, 5 insertions(+), 13 deletions(-)
diff --git a/Bio/TogoWS/__init__.py b/Bio/TogoWS/__init__.py
index a52d89a6d..2669d8c5f 100644
--- a/Bio/TogoWS/__init__.py
+++ b/Bio/TogoWS/__init__.py
@@ -100,7 +100,7 @@ def entry(db, id, format=None, field=None):
EFetch, available in Biopython as Bio.Entrez.efetch(...), but that
does not offer field extraction.
"""
- global _entry_db_names, _entry_db_fields, fetch_db_formats
+ global _entry_db_names
if _entry_db_names is None:
_entry_db_names = _get_entry_dbs()
if db not in _entry_db_names:
diff --git a/BioSQL/BioSeqDatabase.py b/BioSQL/BioSeqDatabase.py
index dadedbceb..32cbd85aa 100644
--- a/BioSQL/BioSeqDatabase.py
+++ b/BioSQL/BioSeqDatabase.py
@@ -238,8 +238,7 @@ class DBServer:
"""Add a new database to the server and return it."""
# make the database
sql = (
- "INSERT INTO biodatabase (name, authority, description)"
- " VALUES (%s, %s, %s)"
+ "INSERT INTO biodatabase (name, authority, description) VALUES (%s, %s, %s)"
)
self.adaptor.execute(sql, (db_name, authority, description))
return BioSeqDatabase(self.adaptor, db_name)
@@ -808,7 +807,6 @@ class BioSeqDatabase:
"""
db_loader = Loader.DatabaseLoader(self.adaptor, self.dbid, fetch_NCBI_taxonomy)
num_records = 0
- global _POSTGRES_RULES_PRESENT
for cur_record in record_iterator:
num_records += 1
# Hack to work around BioSQL Bug 2839 - If using PostgreSQL and
diff --git a/Tests/common_BioSQL.py b/Tests/common_BioSQL.py
index 835e71284..97a351c4b 100644
--- a/Tests/common_BioSQL.py
+++ b/Tests/common_BioSQL.py
@@ -74,8 +74,7 @@ def temp_db_filename():
def check_config(dbdriver, dbtype, dbhost, dbuser, dbpasswd, testdb):
"""Verify the database settings work for connecting."""
- global DBDRIVER, DBTYPE, DBHOST, DBUSER, DBPASSWD, TESTDB, DBSCHEMA
- global SYSTEM, SQL_FILE
+ global DBDRIVER, DBTYPE, DBHOST, DBUSER, DBPASSWD, TESTDB, DBSCHEMA, SQL_FILE
DBDRIVER = dbdriver
DBTYPE = dbtype
DBHOST = dbhost
diff --git a/Tests/common_BioSQL_online.py b/Tests/common_BioSQL_online.py
index edcdb129b..6c0550662 100644
--- a/Tests/common_BioSQL_online.py
+++ b/Tests/common_BioSQL_online.py
@@ -42,8 +42,7 @@ SYSTEM = platform.system()
def share_config(dbdriver, dbtype, dbhost, dbuser, dbpasswd, testdb):
"""Make sure we can access the DB settings from this file."""
- global DBDRIVER, DBTYPE, DBHOST, DBUSER, DBPASSWD, TESTDB, DBSCHEMA
- global SYSTEM, SQL_FILE
+ global DBDRIVER, DBTYPE, DBHOST, DBUSER, DBPASSWD, TESTDB
DBDRIVER = dbdriver
DBTYPE = dbtype
DBHOST = dbhost
@@ -56,8 +55,7 @@ class TaxonomyTest(unittest.TestCase):
"""Test proper insertion and retrieval of taxonomy data."""
def setUp(self):
- global DBDRIVER, DBTYPE, DBHOST, DBUSER, DBPASSWD, TESTDB, DBSCHEMA
- global SYSTEM, SQL_FILE
+ global TESTDB
Entrez.email = "biopython@biopython.org"
# create TESTDB
diff --git a/Tests/run_tests.py b/Tests/run_tests.py
index 0f3551904..c16349ff6 100755
--- a/Tests/run_tests.py
+++ b/Tests/run_tests.py
@@ -231,7 +231,6 @@ class TestRunner(unittest.TextTestRunner):
output = StringIO()
# Restore the language and thus default encoding (in case a prior
# test changed this, e.g. to help with detecting command line tools)
- global SYSTEM_LANG
os.environ["LANG"] = SYSTEM_LANG
# Always run tests from the Tests/ folder where run_tests.py
# should be located (as we assume this with relative paths etc)
diff --git a/Tests/test_Tutorial.py b/Tests/test_Tutorial.py
index 832c50159..0300defdc 100644
--- a/Tests/test_Tutorial.py
+++ b/Tests/test_Tutorial.py
@@ -228,7 +228,6 @@ for rst in files:
continue
def funct(n, d, f):
- global tutorial_base
method = lambda x: None # noqa: E731
if f:
p = os.path.join(tutorial_base, f)
@@ -271,7 +270,6 @@ class TutorialTestCase(unittest.TestCase):
)
def tearDown(self):
- global original_path
os.chdir(original_path)
# files currently don't get created during test with python3.5 and pypy
# remove files created from chapter_phylo.tex