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

config: Missing correspondence silently fails? sections = ["{WROTE_AB}", ...] and known_{meant_abc} #1331

Closed
EricCousineau-TRI opened this issue Jul 19, 2020 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@EricCousineau-TRI
Copy link

EricCousineau-TRI commented Jul 19, 2020

Would it be possible to have isort complain if sections is defined without a corresponding known_{snake_case} definition? -- or conversely, if known_{snake_case} is defined, but is not used in sections?

I just spent some time chasing down an issue where section correspondence didn't exist, but it silently failed.

In my specific cast, I had the following TOML config portion:

[tool.isort]
# ...
# [ Sections ]
# See: https://github.com/timothycrosley/isort#custom-sections-and-ordering
# This determines the ordering of imports.
sections = [
    # {builtin}
    "FUTURE",
    # {builtin} + extra_standard_library
    "STDLIB",
    # known_third_party
    "THIRDPARTY",
    # known_robotlocomotion_upstream
    "ROBOTLOOMOTION_UPSTREAM",
    # known_first_party
    "FIRSTPARTY",
    # {builtin}
    "LOCALFOLDER",
]
# TODO(eric.cousineau): Rename to LCM ecosystem?
known_robotlocomotion_upstream = [
    "bot_core",
]
default_section = "THIRDPARTY"

But isort==5.1.3 was formatting the following file:

import time

import numpy as np

import bot_core

into this:

import time

import bot_core
import numpy as np

which was not what I wanted.

In the end, it was because I misspelled "ROBOTLOOMOTION_UPSTREAM" - it was missing the C 🤦

@EricCousineau-TRI EricCousineau-TRI changed the title config: sections = ["{WROTE_AB}", ...] and known_{meant_x} config: Missing correspondence silently fails? sections = ["{WROTE_AB}", ...] and known_{meant_abc} Jul 19, 2020
@timothycrosley timothycrosley added the enhancement New feature or request label Jul 20, 2020
@timothycrosley timothycrosley added this to the 5.2.0 milestone Jul 20, 2020
@timothycrosley
Copy link
Member

Thanks for reporting this! I think the suggested approach is solid and I'll be aiming to get the improved error handling / warning in the 5.2.0 release.

Thanks!

~Timothy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants