Skip to content

Relative paths for --black-config setting #13

@peterjc

Description

@peterjc

Consider we have a user's "global" black configuration in ~/repositories/black.toml and multiple projects under this folder, where ~/repositories/project/.flake8 contains:

[flake8]
black_config=../black.toml

Then, you might run:

cd ~/repositories/project/
flake8 tests/
cd tests/
flake8 .

Both the above should find the ~/repositories/project/.flake8 file, which will load ../black.toml as the location of the black configuration file, which should be converted relative to ~/repositories/project/.flake8 giving ~/repositories/black.toml.

However, now suppose the users does the following, where the command line setting will override any values set via the flake8 configuration files (see https://gitlab.com/pycqa/flake8/issues/560 for clarifying this):

cd ~/repositories/project/
flake8 --black-config ../black.toml tests/
cd tests/
flake8 --black-config ../../black.toml .

Here the relative paths ../black.toml and ../../black.toml should both be interpreted relative to the current directory, and both give ~/repositories/black.toml.

However, if the plugin just gets a string ../black.toml or ../../black.toml, how is it to infer the starting path (a config file location or the present directory)? i.e. How was the setting given (which config file, or was it the command line)?

Cross reference https://gitlab.com/pycqa/flake8/issues/561

If we can't tell, we could be pragmatic and just try both, and maybe give an error if both interpretations exist but are different paths?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingquestionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions