MannLabs / alphabase

Infrastructure of AlphaX ecosystem
https://alphabase.readthedocs.io
Apache License 2.0
31 stars 9 forks source link

158 ruff linting (#158) #159

Closed mschwoer closed 7 months ago

mschwoer commented 7 months ago

The next step towards clean code :-) (added a lot of reviewers to give you a feeling for these kind of changes) see issue #158 for high-level context

I chose to add # noqa whenever I was not 100% sure that I am not breaking something. For the "unused imports", we should discuss if this code could be removed.

Also, I think ruff found two bugs (marked with TODOs)

Just for full transparency, this was the output on the base branch:

>  pre-commit run --all-files
alphabase/constants/element.py:1:1: F403 `from .atom import *` used; unable to detect undefined names
alphabase/constants/isotope.py:10:5: F401 [*] `alphabase.constants.element.CHEM_MONO_MASS` imported but unused
alphabase/io/hdf.py:7:8: F401 [*] `warnings` imported but unused
alphabase/io/psm_reader/__init__.py:2:1: F403 `from alphabase.psm_reader import *` used; unable to detect undefined names
alphabase/io/psm_reader/alphapept_reader.py:1:1: F403 `from alphabase.psm_reader.alphapept_reader import *` used; unable to detect undefined names
alphabase/io/psm_reader/dia_psm_reader.py:1:1: F403 `from alphabase.psm_reader.dia_psm_reader import *` used; unable to detect undefined names
alphabase/io/psm_reader/dia_search_reader.py:2:1: F403 `from alphabase.psm_reader.dia_psm_reader import *` used; unable to detect undefined names
alphabase/io/psm_reader/maxquant_reader.py:1:1: F403 `from alphabase.psm_reader.maxquant_reader import *` used; unable to detect undefined names
alphabase/io/psm_reader/msfragger_reader.py:1:1: F403 `from alphabase.psm_reader.msfragger_reader import *` used; unable to detect undefined names
alphabase/io/psm_reader/pfind_reader.py:1:1: F403 `from alphabase.psm_reader.pfind_reader import *` used; unable to detect undefined names
alphabase/io/psm_reader/psm_reader.py:1:1: F403 `from alphabase.psm_reader.psm_reader import *` used; unable to detect undefined names
alphabase/peptide/fragment.py:3:46: F401 [*] `typing.TYPE_CHECKING` imported but unused
alphabase/peptide/fragment.py:4:8: F401 [*] `warnings` imported but unused
alphabase/peptide/fragment.py:6:8: F401 [*] `logging` imported but unused
alphabase/peptide/fragment.py:9:1: F403 `from alphabase.peptide.mass_calc import *` used; unable to detect undefined names
alphabase/peptide/fragment.py:12:5: F401 [*] `alphabase.constants.element.MASS_H2O` imported but unused
alphabase/peptide/fragment.py:14:5: F401 [*] `alphabase.constants.element.MASS_NH3` imported but unused
alphabase/peptide/fragment.py:15:5: F401 [*] `alphabase.constants.element.MASS_H` imported but unused
alphabase/peptide/fragment.py:16:5: F401 [*] `alphabase.constants.element.MASS_C` imported but unused
alphabase/peptide/fragment.py:17:5: F401 [*] `alphabase.constants.element.MASS_O` imported but unused
alphabase/peptide/fragment.py:22:5: F401 [*] `alphabase.peptide.precursor.update_precursor_mz` imported but unused
alphabase/peptide/fragment.py:414:33: F405 `calc_b_y_and_peptide_masses_for_same_len_seqs` may be undefined, or defined from star imports
alphabase/peptide/fragment.py:1333:9: F841 Local variable `elution_group` is assigned to but never used
alphabase/protein/fasta.py:1254:9: E722 Do not use bare `except`
alphabase/psm_reader/__init__.py:3:5: F401 `alphabase.psm_reader.psm_reader.psm_reader_provider` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
alphabase/psm_reader/__init__.py:4:5: F401 `alphabase.psm_reader.psm_reader.psm_reader_yaml` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
alphabase/psm_reader/__init__.py:5:5: F401 `alphabase.psm_reader.psm_reader.PSMReaderBase` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
alphabase/psm_reader/__init__.py:7:51: F401 `alphabase.psm_reader.alphapept_reader.AlphaPeptReader` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
alphabase/psm_reader/__init__.py:9:5: F401 `alphabase.psm_reader.dia_psm_reader.DiannReader` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
alphabase/psm_reader/__init__.py:10:5: F401 `alphabase.psm_reader.dia_psm_reader.SpectronautReader` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
alphabase/psm_reader/__init__.py:11:5: F401 `alphabase.psm_reader.dia_psm_reader.SwathReader` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
alphabase/psm_reader/__init__.py:12:5: F401 `alphabase.psm_reader.dia_psm_reader.SpectronautReportReader` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
alphabase/psm_reader/__init__.py:14:50: F401 `alphabase.psm_reader.maxquant_reader.MaxQuantReader` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
alphabase/psm_reader/__init__.py:15:47: F401 `alphabase.psm_reader.pfind_reader.pFindReader` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
alphabase/psm_reader/__init__.py:16:51: F401 `alphabase.psm_reader.msfragger_reader.MSFragger_PSM_TSV_Reader` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
alphabase/psm_reader/__init__.py:17:46: F401 `alphabase.psm_reader.sage_reader.SageReaderTSV` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
alphabase/psm_reader/__init__.py:17:61: F401 `alphabase.psm_reader.sage_reader.SageReaderParquet` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
alphabase/psm_reader/__init__.py:20:55: F401 `alphabase.psm_reader.msfragger_reader.MSFraggerPepXML` imported but unused; consider using `importlib.util.find_spec` to test for availability
alphabase/psm_reader/msfragger_reader.py:10:54: F401 [*] `alphabase.constants.atom.MASS_PROTON` imported but unused
alphabase/psm_reader/msfragger_reader.py:15:1: E722 Do not use bare `except`
alphabase/psm_reader/psm_reader.py:3:8: F401 [*] `io` imported but unused
alphabase/psm_reader/psm_reader.py:73:16: E713 [*] Test for membership should be `not in`
alphabase/psm_reader/psm_reader.py:342:16: E713 [*] Test for membership should be `not in`
alphabase/psm_reader/psm_reader.py:344:16: E713 [*] Test for membership should be `not in`
alphabase/psm_reader/psm_reader.py:346:16: E713 [*] Test for membership should be `not in`
alphabase/psm_reader/psm_reader.py:410:21: E713 [*] Test for membership should be `not in`
alphabase/quantification/quant_reader/config_dict_loader.py:103:8: E721 Do not compare types, use `isinstance()`
alphabase/quantification/quant_reader/config_dict_loader.py:105:19: E711 Comparison to `None` should be `cond is None`
alphabase/quantification/quant_reader/config_dict_loader.py:113:8: E721 Do not compare types, use `isinstance()`
alphabase/quantification/quant_reader/config_dict_loader.py:115:20: E711 Comparison to `None` should be `cond is None`
alphabase/quantification/quant_reader/longformat_reader.py:7:8: F401 [*] `sys` imported but unused
alphabase/quantification/quant_reader/plexdia_reformatter.py:50:1: E402 Module level import not at top of file
alphabase/quantification/quant_reader/quantreader_utils.py:2:23: E711 Comparison to `None` should be `cond is None`
alphabase/quantification/quant_reader/quantreader_utils.py:19:9: E722 Do not use bare `except`
alphabase/quantification/quant_reader/table_reformatter.py:1:8: F401 [*] `itertools` imported but unused
alphabase/quantification/quant_reader/table_reformatter.py:122:24: E711 Comparison to `None` should be `cond is None`
alphabase/quantification/quant_reader/table_reformatter.py:182:25: E711 Comparison to `None` should be `cond is not None`
alphabase/quantification/quant_reader/wideformat_reader.py:9:5: F841 Local variable `protein_cols` is assigned to but never used
alphabase/quantification/quant_reader/wideformat_reader.py:10:5: F841 Local variable `ion_cols` is assigned to but never used
alphabase/scoring/ml_scoring.py:5:26: F401 [*] `sklearn.base.BaseEstimator` imported but unused
alphabase/scoring/ml_scoring.py:10:5: F401 [*] `alphabase.scoring.fdr.calculate_fdr_from_ref` imported but unused
alphabase/scoring/ml_scoring.py:11:5: F401 [*] `alphabase.scoring.fdr.fdr_to_q_values` imported but unused
alphabase/spectral_library/base.py:261:17: F541 [*] f-string without any placeholders
alphabase/spectral_library/base.py:312:16: F401 [*] `alphabase.protein.protein_level_decoy` imported but unused
alphabase/spectral_library/decoy.py:5:23: F401 [*] `functools.partial` imported but unused
alphabase/spectral_library/decoy.py:7:30: F401 [*] `alphabase.io.hdf.HDF_File` imported but unused
alphabase/spectral_library/flat.py:10:39: F401 [*] `alphabase.peptide.precursor` imported but unused
alphabase/spectral_library/reader.py:2:8: F401 [*] `os` imported but unused
alphabase/spectral_library/reader.py:8:55: F401 [*] `alphabase.io.psm_reader.dia_search_reader.SpectronautReader` imported but unused
alphabase/spectral_library/reader.py:14:40: F401 [*] `alphabase.constants._const.CONST_FILE_FOLDER` imported but unused
alphabase/spectral_library/reader.py:15:34: F401 [*] `alphabase.yaml_utils.load_yaml` imported but unused
alphabase/spectral_library/validate.py:189:34: F541 [*] f-string without any placeholders
alphabase/statistics/regression.py:6:44: F401 [*] `sklearn.utils.estimator_checks.check_estimator` imported but unused
alphabase/statistics/regression.py:262:13: F841 Local variable `y_m` is assigned to but never used
alphabase/utils.py:2:8: F401 [*] `os` imported but unused
alphabase/utils.py:3:8: F401 [*] `sys` imported but unused
docs/conf.py:53:12: F541 [*] f-string without any placeholders
release/pyinstaller/alphabase_pyinstaller.py:8:12: F821 Undefined name `e`
setup.py:6:8: F401 [*] `os` imported but unused
Found 79 errors.
[*] 38 fixable with the `--fix` option (9 hidden fixes can be enabled with the `--unsafe-fixes` option).