Hey Ian, answers inline: On Tue, Jul 7, 2015 at 4:36 PM, Ian Cordasco <graffatcolmin...@gmail.com> wrote:
> Hey Willy, > > Responses in-line: > > On Tue, Jul 7, 2015 at 4:05 AM, Willy Wu via code-quality > <code-quality@python.org> wrote: > > Hey all, > > > > We use flake8 at Dropbox and are pretty happy with it. But one small > issue > > is the way that flake8 configuration gets discovered. We use the > > per-project configuration via setup.cfg files which are checked into > source > > control, but flake8 only considers the first setup.cfg in the directory > path > > (regardless of whether it contains a flake8 section or not). This > forces us > > to duplicate our [flake8] configuration across all of our various > > setup.cfgs. > > > > Said in crude ascii form, this is a simplified version of our project > > layout: > > - repo root > > |- setup.cfg (default values) > > \- subservice #1 > > \- setup.cfg (which has non-flake8 overrides for subservice #1) > > \- subservice #2 > > \- setup.cfg (which similarly contains non-flake8 overrides for > > subservice #2) > > So... to be clear... you're putting all of your Flake8 configuration > in "repo root/setup.cfg" but you have other setup.cfg files in > sub-directories. How are you running Flake8 (or perhaps, where are you > running Flake8) such that it picks up the setup.cfg files in the > sub-directories? Am I correct in assuming that you are running it in > that sub-directory? If not, can you give me the command-invocation > that triggers this? Flake8 actually gets run automatically by our lint tools during code diffs, but ultimately the command that runs is: $ flake8 /Users/name/{repo_root}/{path_to_file} But the current working directory during the command that kicks off flake8 is {repo_root}, so I was hoping that flake8 would search anywhere between the file's directory and the current working directory when trying to discover various setup.cfgs to consider. I think the source of our confusion is that we use py.test as our unit test runner, and they only consider setup.cfg a match if it contains a [pytest] section, so there's kind of a tension between how you guys and pytest are resolving configs. Let me know what else you need? > > > But before I go off trying to patch flake8 code, is there relevant > > background on why you guys don't try to discover the first setup.cfg > with a > > flake8 section, but instead just consider the first encountered > setup.cfg? > > We've seen teams accidentally break flake8 checking whenever they add > > setup.cfg files for non-flake8 projects, and the "fix" is to copy/paste > the > > flake8 section into those new files. > > The easiest answer is simplicity. Flake8 piggy-backs off of pep8 when > it comes to finding config files and consuming them. > > I think there were a couple of people who had requested that we search > through all parent directories until we could find no parent directory > to search for configuration files, but I hope you can understand why > that is not feasible in the slightest. I believe the two places we > search by default are: > > - Current working directory > - User's home directory > > Traversing sub-directories is a little bit less offensive, but still > not optimal. There is the option to specify the config file > explicitly, but that doesn't help our users that much unless they have > some (honestly bizarre) setup where they're using something like > autoenv + shell aliases for flake8, e.g., autoenv could pick up the > right config file path when changing into a directory and `flake8` is > aliased to `/path/to/flake8 --config=$ENVVARWITHPATH` > > That's definitely a bit over-the-top and not exactly user-friendly. > > > Or alternatively, should we be doing something different with our project > > layout as a workaround? It's entirely possible that we should be > > configuring things differently overall...? > > That's tough to say honestly. I don't really feel like it's my place > (or anyone else's place) to tell you how to structure your project > layouts. That decision should be 100% in your court. > > I'd still like to know a bit more about exactly how you're invoking > flake8 in this case. I don't have a clear enough understanding of the > problem to really be very helpful. > > Cheers, > Ian >
_______________________________________________ code-quality mailing list code-quality@python.org https://mail.python.org/mailman/listinfo/code-quality