Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F811: Message unclear in Notebook context #6672

Closed
Tracked by #5188
MichaReiser opened this issue Aug 18, 2023 · 0 comments · Fixed by #9387
Closed
Tracked by #5188

F811: Message unclear in Notebook context #6672

MichaReiser opened this issue Aug 18, 2023 · 0 comments · Fixed by #9387
Assignees
Labels
wish Not on the current roadmap; maybe in the future

Comments

@MichaReiser
Copy link
Member

Input

{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import random\n",
    "import math"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Some explanation\n",
    "\n",
    "See below"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "try:\n",
    "    print()\n",
    "except ValueError:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import random\n",
    "import pprint\n",
    "\n",
    "random.randint(10, 20)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "foo = 1\n",
    "if foo is 2:\n",
    "    raise ValueError(f\"Invalid foo: {foo is 1}\")"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}

Output

test-notebook.ipynb:cell 5:1:8: F811 Redefinition of unused `random` from line 1

The message is unclear because the first import is on line 1 in cell 1.

@MichaReiser MichaReiser added the wish Not on the current roadmap; maybe in the future label Aug 18, 2023
@charliermarsh charliermarsh self-assigned this Jan 4, 2024
charliermarsh added a commit that referenced this issue Jan 4, 2024
## Summary

Ensures that any lint rules that include line locations render them as
relative to the cell (and include the cell number) when inside a Jupyter
notebook.

Closes #6672.

## Test Plan

`cargo test`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wish Not on the current roadmap; maybe in the future
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants