diff --git a/repeats/AnnotRedRepeats.py b/repeats/AnnotRedRepeats.py index 9017972afb..1a2a074c7a 100755 --- a/repeats/AnnotRedRepeats.py +++ b/repeats/AnnotRedRepeats.py @@ -7,7 +7,7 @@ # pyenv local 3.7.6 # pip install --user sqlalchemy==1.3.23 sqlalchemy_utils pymysql # -# Copyright [2020-21] EMBL-European Bioinformatics Institute +# Copyright [2020-24] EMBL-European Bioinformatics Institute import argparse import os @@ -15,14 +15,15 @@ import errno import subprocess -import sqlalchemy as db -import sqlalchemy_utils as db_utils +from typing import TYPE_CHECKING -# sqlalchemy requires MySQLdb but MySQLdb doesn't support Python 3.x -# pymysql can be imported and used instead -import pymysql - -pymysql.install_as_MySQLdb() +if TYPE_CHECKING: # False at runtime + import sqlalchemy as db + import sqlalchemy_utils as db_utils + # sqlalchemy requires MySQLdb but MySQLdb doesn't support Python 3.x + # pymysql can be imported and used instead + import pymysql + pymysql.install_as_MySQLdb() def fetch_repeats_FASTA(logpath, synpath, annotdir, minlen): diff --git a/repeats/Red2Ensembl.py b/repeats/Red2Ensembl.py index bbff540d8f..4b315bf042 100755 --- a/repeats/Red2Ensembl.py +++ b/repeats/Red2Ensembl.py @@ -7,7 +7,7 @@ # pyenv local 3.7.6 # pip install --user sqlalchemy==1.3.23 sqlalchemy_utils pymysql # -# Copyright [2020-22] EMBL-European Bioinformatics Institute +# Copyright [2020-24] EMBL-European Bioinformatics Institute import argparse import sys @@ -19,14 +19,15 @@ import errno import subprocess -import sqlalchemy as db -import sqlalchemy_utils as db_utils +from typing import TYPE_CHECKING -# sqlalchemy requires MySQLdb but MySQLdb doesn't support Python 3.x -# pymysql can be imported and used instead -import pymysql - -pymysql.install_as_MySQLdb() +if TYPE_CHECKING: # False at runtime + import sqlalchemy as db + import sqlalchemy_utils as db_utils + # sqlalchemy requires MySQLdb but MySQLdb doesn't support Python 3.x + # pymysql can be imported and used instead + import pymysql + pymysql.install_as_MySQLdb() def _is_gz_file(filepath):