Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
F
flake8
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 40
    • Issues 40
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 8
    • Merge Requests 8
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • PyCQA
  • flake8
  • Issues
  • #518

Closed
Open
Opened Mar 08, 2019 by Charles Frye@charlesfrye

Project-level configuration files not found when run inside a Jupyer notebook

Please describe how you installed Flake8

I installed flake8 on Ubuntu 18.04 with pip inside a virtualenv

$ pip install flake8

Please provide the exact, unmodified output of flake8 --bug-report

{
  "dependencies": [
    {
      "dependency": "entrypoints",
      "version": "0.3"
    }
  ],
  "platform": {
    "python_implementation": "CPython",
    "python_version": "3.6.7",
    "system": "Linux"
  },
  "plugins": [
    {
      "is_local": false,
      "plugin": "mccabe",
      "version": "0.6.1"
    },
    {
      "is_local": false,
      "plugin": "pycodestyle",
      "version": "2.5.0"
    },
    {
      "is_local": false,
      "plugin": "pyflakes",
      "version": "2.1.1"
    }
  ],
  "version": "3.7.7"
}

Please describe the problem or feature

While using a downstream repository to perform linting on the cells of Jupyter notebooks, I noticed that my configuration files were not being respected, even though they were respected when invoking flake8 from the command line.

If this is a bug report, please explain with examples (and example code) what you expected to happen and what actually happened.

If I execute the following

from flake8.api import legacy
style_guide = legacy.get_style_guide()
style_guide.options

inside a Python terminal, the ignore attribute contains the ignores from my project-level specification, as desired.

If I run the same lines in a Jupyter notebook in the same directory, only the default ignores are included. ignores specified in a .flake8 file in that directory do not appear.

I did a little bit of digging to try and determine where the problem is occurring, and it seems to be somewhere between the ConfigFileFinder and the Application. The code below is collected in a GitHub gist here.

If I execute the internals of get_style_guide up to 37 in api.legacy in order to gain direct access to the application, like so:

import flake8
from flake8.formatting import base as formatter
from flake8.main import application as app

application = app.Application()

application.parse_preliminary_options_and_args([])
flake8.configure_logging(
        application.prelim_opts.verbose, application.prelim_opts.output_file
    )
application.make_config_finder()
application.find_plugins()
application.register_plugin_options()
application.parse_configuration_and_cli([])

then, in a Jupyter notebook, application.config_finder.local_config_files returns an empty list, indicating that the local config files were not found, but the same procedure returns a non-empty list in a Python terminal.

But if, inside the Jupyter notebook, I then run the following:

import flake8.options.config as config
cff = config.ConfigFileFinder(application.program_name, [], [])
cff.local_config_files()

the local config file is present. I was unable to dig any further to find out where the divergence in behavior is occurring.

Many thanks for providing an awesome tool! Your work is very much appreciated.

Edited Mar 08, 2019 by Charles Frye
Assignee
Assign to
3.7.8
Milestone
3.7.8
Assign milestone
Time tracking
None
Due date
None
Reference: pycqa/flake8#518