Skip to content

MAINT: Code-hygiene quick wins: dead code, bare excepts, broken test block, comparison anti-patterns #882

Description

@mmcky

Problem

Small, independent hygiene defects that don't merit separate issues:

  1. quantecon/util/common_messages.py — one message string, referenced nowhere, untouched since 2018, pointing to the defunct continuum.io downloads page. Delete.
  2. quantecon/__init__.py:9-13 — bare except: (catches KeyboardInterrupt/SystemExit during import) around import numba, discarding the original exception and raising a conda-specific message — wrong for pip users, and it hides the real traceback in the common numba/llvmlite ABI-mismatch case. Replace with except ImportError as e: raise ImportError(<pip-and-conda message>) from e, or delete the guard and let the natural ImportError speak. The file-level # flake8: noqa masks this today.
  3. quantecon/tests/test_quadsum.py:59-63 — nose-era __main__ block calling undefined names (test_simplesum, test_identitysum; dangling uncalled test_m_identitysum). Running the file directly raises NameError; the source of all 3 F821s in the package. Delete the block.
  4. Comparison anti-patterns: _dle.py:246 isinstance(...) == True; _dle.py:280 and util/notebooks.py:77 type(x) != np.ndarrayisinstance (deep DLE work stays in Refactor DLE (_dle.py) to use native scalars and 1-D arrays instead of (1, 1)/2-D matrix conventions #844 — these lines needn't wait).
  5. quantecon/markov/tests/test_graph_tools.py:137 — bare except:except KeyError:.
  6. util/timing.py:247__exit__ binds exc_type, exc_val, exc_tb unused. game_theory/game_generators/__init__.py:6 — the package's lone import *; make it explicit.

Acceptance criteria

  • Full flake8 quantecon run reports zero F821/E722/E712/E721
  • common_messages.py gone; suite green; no behavior change anywhere else

From the July 2026 technical-debt audit (AI-assisted; claims verified against 28d4b3b on 2026-07-25).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions