Fix/linters#2774
Merged
Merged
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
After deleting variables, some bare expressions were deleted:
Bare expressions deleted (no side effects — entire line removed):
File: brain_observatory/circle_plots.py
Deleted expression: r * np.cos(angle), r * np.sin(angle)
Why: Pure arithmetic
────────────────────────────────────────
File: brain_observatory/ecephys/.../view_blocks.py
Deleted expression: recorded_blocks[0] → pass
Why: Bare index in else clause
────────────────────────────────────────
File: brain_observatory/eye_tracking/.../DLC_Ellipse_Fitting.py
Deleted expression: 1-frac_completed
Why: Pure arithmetic
────────────────────────────────────────
File: internal/brain_observatory/demix_report.py
Deleted expression: np.zeros(mask.shape)
Why: Array allocated and discarded
────────────────────────────────────────
File: internal/brain_observatory/frame_stream.py
Deleted expression: np.prod(self.frame_shape)
Why: Pure computation
────────────────────────────────────────
File: internal/brain_observatory/roi_filter.py
Deleted expression: create_feature_array(...) → pass
Why: Returns value, no mutation
────────────────────────────────────────
File: internal/ephys/plot_qc_figures.py
Deleted expression: cell_features["long_squares"]["sweeps"]
Why: Dict lookup
────────────────────────────────────────
File: internal/ephys/plot_qc_figures3.py
Deleted expression: cell_features["long_squares"]["sweeps"]
Why: Dict lookup
────────────────────────────────────────
File: internal/model/GLM.py
Deleted expression: kbasprs['b']
Why: Dict lookup
────────────────────────────────────────
File: internal/model/biophysical/fit_stage_1.py
Deleted expression: neuronal_model_data['specimen_id']
Why: Dict lookup
────────────────────────────────────────
File: internal/model/biophysical/make_deap_fit_json.py
Deleted expression: os.path.realpath(os.curdir)
Why: Pure path op
────────────────────────────────────────
File: internal/model/biophysical/passive_fitting/preprocess.py
Deleted expression: down_idxs[1] - down_idxs[0]
Why: Pure arithmetic
────────────────────────────────────────
File: internal/model/glif/error_functions.py
Deleted expression: input_data['subthreshold_long_square_voltage_variance'], np.arange(...)*experiment.neuron.dt, [e.data['interpolated_ISI']] (dead code after raise)
Why: Dict lookup, pure computation, unreachable
────────────────────────────────────────
File: internal/model/glif/preprocess_neuron.py
Deleted expression: sweep_index[...][RESTING_POTENTIAL]*1e-3, long_square_config['all'], long_square_config['subthreshold'], np.mean(El_test_list)
Why: Dict lookups, pure computation
────────────────────────────────────────
File: internal/model/glif/spike_cutting.py
Deleted expression: np.var(xdata)
Why: Pure computation
────────────────────────────────────────
File: internal/pipeline_modules/IVSCC/ephys_nwb/qc.py
Deleted expression: sweep_data['response'], sweep_data['sampling_rate']
Why: Dict lookups
────────────────────────────────────────
File: internal/pipeline_modules/run_neuropil_correction.py
Deleted expression: np.array([...]).mean()
Why: Pure computation
────────────────────────────────────────
File: internal/pipeline_modules/run_observatory_container_thumbnails.py
Deleted expression: input_file['output_json']
Why: Dict lookup
────────────────────────────────────────
File: model/glif/glif_neuron_methods.py
Deleted expression: tcs['voltage'][-1]
Why: Dict/index lookup
────────────────────────────────────────
File: brain_observatory/behavior/swdb/summary_figures.py
Deleted expression: int(session.metadata['ophys_frame_rate'])
Why: Pure type conversion
Bare expressions kept (have side effects):
┌────────────────────────────────────────────────────────┬──────────────────────────────────┐
│ Expression │ Why kept │
├────────────────────────────────────────────────────────┼──────────────────────────────────┤
│ hero_sweep.sweep_feature("adapt"/"latency"/"mean_isi") │ Forces lazy feature caching │
├────────────────────────────────────────────────────────┼──────────────────────────────────┤
│ swp.sweep_feature("v_baseline") │ Same caching pattern │
├────────────────────────────────────────────────────────┼──────────────────────────────────┤
│ i_vec.as_numpy() │ NEURON vector conversion │
├────────────────────────────────────────────────────────┼──────────────────────────────────┤
│ subprocess.check_output([...]) (3 calls) │ Runs external fitting processes │
├────────────────────────────────────────────────────────┼──────────────────────────────────┤
│ p.map(func, types) │ Multiprocessing execution │
├────────────────────────────────────────────────────────┼──────────────────────────────────┤
│ description.manifest.get_path(...) │ Manifest path resolution │
├────────────────────────────────────────────────────────┼──────────────────────────────────┤
│ plt.subplot2grid(...) │ Creates subplot in figure layout │
├────────────────────────────────────────────────────────┼──────────────────────────────────┤
│ All allensdk/test/ expressions │ Smoke tests exercising APIs │
└────────────────────────────────────────────────────────┴──────────────────────────────────┘
- E722: Replace 55 bare `except:` with `except Exception:` (32 files) - E701: Split 29 single-line compound statements onto separate lines - F401: Add `__all__` to 5 `__init__.py` re-export files, noqa 2 keras availability checks - F507: Fix format string placeholder mismatch in glif_optimizer_neuron - Configure ruff and flake8 to suppress E402, E741, F403, F405 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
f7951c7 to
0bca126
Compare
dyf
approved these changes
Feb 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview:
Fix ~950 lint violations across 269 files using ruff auto-fixes and targeted manual corrections. No formatting or behavioral changes — strictly lint error resolution and linter configuration.
Addresses:
N/A — maintenance/code health improvement.
Type of Fix:
functionality to not work as expected)
Solution:
Apply lint fixes incrementally in order of risk, from fully automated ruff safe fixes to manual corrections requiring judgment (e.g. pandas boolean comparisons). Configure ruff and flake8 to suppress rules that don't apply well to this codebase (E402 import order, E741 ambiguous names, F403/F405 wildcard imports). Set
line-length = 120in both tools for consistency.Changes:
ruff --fixsafe auto-fixes (~250 files) — trailing whitespace, unused imports, comparison ordering, etc.== None→is None, lambda assignments →defstatements== True/False→ idiomatic Python; pandas cases use~seriesinstead ofnot seriesto avoidValueError# noqa: F841for tuple unpacking where removal isn't possibleexcept:→except Exception:(72 occurrences)__all__for intentional re-exports;# noqafor conditional imports.flake8config — setmax-line-length = 120, add extend-ignore for E402, E741, F403, F405, W503pyproject.toml— add[tool.ruff]withline-length = 120and matching lint ignore listValidation:
ruff check allensdkpasses cleanpytest— 1931 passed, 186 skipped, 1 pre-existing error (h5py fixture unrelated to this branch)notebook_runnerCI workflow executed successfullyScreenshots:
N/A — no UI changes.
Unit Tests:
Existing test suite passes; no new tests needed (no behavioral changes).
Script to reproduce error and fix:
Configuration details:
Python 3.13, Fedora 43, ruff 0.11.x
Checklist
Allen Institute Contribution Guidelines
Numpy Standards
appropriate
rc/x.y.z as its merge target
Notes:
This PR is strictly lint fixes — no formatting or runtime behavior changes. The merge target is
masterrather than anrc/branch since this repo is in maintenance mode with no active release candidates.The commit history is structured for reviewable progression:
fix: apply safe ruff auto-fixes— zero-risk automated fixesfix: E711, E731— none-comparison and lambda assignmentfix: E712— boolean comparison with idiomatic pandasfix: F841— unused variablesfix: E722, E701, F401, F507— bare except, multi-statement lines, unused imports, and linter configurationThe E712 pandas fixes deserve attention: ruff's auto-fix would change
series == Falsetonot series, which crashes at runtime withValueError: The truth value of a Series is ambiguous. These were manually fixed to~series.