Skip to content

Doesn't recognize setup.cfg file #564

Closed

Description

Environment data

VS Code version: 1.19.1
Python Extension version: 0.9.1
Python Version: 3.6.3
OS and version: Ubuntu 17.10

On the linting setup, the documentation says than PyLint is activated by default and it provides some ways to configure the extension to work this package, specifically the documentation states than:

Options can also be specified in a pylintrc or .pylintrc file in the workspace folder...

But Pylint also allows the use of a setup.cfg file, which also is accepted as a repository for other Python modules configurations such as Flake8 and Coverage. Would be possible to add that option to the linting setup?

Activity

  1. DonJayamanne commented on Jan 10, 2018

    @DonJayamanne

    Have you tried to check whether this works?
    It should work as long as pylint supports it and is able to automatically locate it based on its search rules.
    Please could you confirm whether this works, if not please provide the following information:

    • Where is your setup.cfg file located with respect to your workspace
    • Where is the file you are linting located with respect to your workspace
    • Sample content of setup.cfg
  2. sebastian-code commented on Jan 10, 2018

    @sebastian-code
    Author

    Hi Don Jayamanne (@DonJayamanne) Thanks for the prompt answer.

    Yes, PyLint and some additional Python packages are compatible with the setup.cfg file, but now than you mention, there is one thing, PyLint only detects automatically the .pylintrc file, to call the setup file you have to use the flag --rcfile=setup.cfg adding the working folder where you want run PyLint.

    My setup.cfg file is inside the projects working directory.
    I'm trying to lint the whole project, but the main content is inside a subfolder.
    The content of my file is the next, I apologize but is long file but i think it is useful for you to have the info:

    [isort]
    default_section = THIRDPARTY
    known_first_party = bootcamp
    known_django = django
    sections = FUTURE,STDLIB,DJANGO,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
    
    [tool:pytest]
    DJANGO_SETTINGS_MODULE=bootcamp.settings
    python_files=tests.py test_*.py *_tests.py
    addopts=--cov=bootcamp --cov-config setup.cfg
    
    [coverage:run]
    source=accountant/*
    omit=*/migrations/*,*/tests/*
    plugins=django_coverage_plugin
    
    [flake8]
    max-line-length=80
    exclude=.tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules,build,dist,*.egg-info
    statistics=True
    
    [pylint]
    ignore=migrations,test
    persistent=no
    load-plugins=pylint_common, pylint_django, pylint_plugin_utils
    jobs=1
    unsafe-load-any-extension=no
    extension-pkg-whitelist=
    optimize-ast=no
    confidence=
    disable=all
    enable=import-error,import-self,reimported,wildcard-import,misplaced-future,deprecated-module,unpacking-non-sequence,invalid-all-object,undefined-all-variable,used-before-assignment,cell-var-from-loop,global-variable-undefined,redefine-in-handler,unused-import,unused-wildcard-import,global-variable-not-assigned,undefined-loop-variable,global-statement,global-at-module-level,bad-open-mode,redundant-unittest-assert,boolean-datetimedeprecated-method,anomalous-unicode-escape-in-string,anomalous-backslash-in-string,not-in-loop,continue-in-finally,abstract-class-instantiated,star-needs-assignment-target,duplicate-argument-name,return-in-init,too-many-star-expressions,nonlocal-and-global,return-outside-function,return-arg-in-generator,invalid-star-assignment-target,bad-reversed-sequence,nonexistent-operator,yield-outside-function,init-is-generator,nonlocal-without-binding,lost-exception,assert-on-tuple,dangerous-default-value,duplicate-key,useless-else-on-loopexpression-not-assigned,confusing-with-statement,unnecessary-lambda,pointless-statement,pointless-string-statement,unnecessary-pass,unreachable,eval-used,exec-used,using-constant-test,bad-super-call,missing-super-argument,slots-on-old-class,super-on-old-class,property-on-old-class,not-an-iterable,not-a-mapping,format-needs-mapping,truncated-format-string,missing-format-string-key,mixed-format-string,too-few-format-args,bad-str-strip-call,too-many-format-args,bad-format-character,format-combined-specification,bad-format-string-key,bad-format-string,missing-format-attribute,missing-format-argument-key,unused-format-string-argumentunused-format-string-key,invalid-format-index,bad-indentation,mixed-indentation,unnecessary-semicolon,lowercase-l-suffix,invalid-encoded-data,unpacking-in-except,import-star-module-level,long-suffix,old-octal-literal,old-ne-operator,backtick,old-raise-syntax,metaclass-assignment,next-method-called,dict-iter-method,dict-view-method,indexing-exception,raising-string,using-cmp-argument,cmp-method,coerce-method,delslice-method,getslice-method,hex-method,nonzero-method,t-method,setslice-method,old-division,logging-format-truncated,logging-too-few-args,logging-too-many-args,logging-unsupported-format,logging-format-interpolation,invalid-unary-operand-type,unsupported-binary-operation,not-callable,redundant-keyword-arg,assignment-from-no-return,assignment-from-none,not-context-manager,repeated-keyword,missing-kwoa,no-value-for-parameter,invalid-sequence-index,invalid-slice-index,unexpected-keyword-arg,unsupported-membership-test,unsubscriptable-object,access-member-before-definition,method-hidden,assigning-non-slot,duplicate-bases,inconsistent-mro,inherit-non-class,invalid-slots,invalid-slots-object,no-method-argument,no-self-argument,unexpected-special-method-signature,non-iterator-returned,arguments-differ,signature-differs,bad-staticmethod-argument,non-parent-init-called,bad-except-order,catching-non-exception,bad-exception-context,notimplemented-raised,raising-bad-type,raising-non-exception,misplaced-bare-raise,duplicate-except,broad-except,nonstandard-exception,binary-op-exception,bare-except,not-async-context-manager,yield-inside-async-function
    output-format=colorized
    files-output=no
    reports=no
    evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
    logging-modules=logging
    max-line-length=80
    ignore-long-lines=^\s*
    single-line-if-stmt=no
    no-space-check=trailing-comma,dict-separator
    max-module-lines=1000
    indent-string='    '
    indent-after-paren=4
    expected-line-ending-format=
    ignore-mixin-members=yes
    ignored-modules=
    ignored-classes=
    generated-members=REQUEST,acl_users,aq_parent,"[a-zA-Z]+_set{1,2}",save,delete
    init-import=no
    dummy-variables-rgx=_$|dummy
    additional-builtins=
    callbacks=cb_,_cb
    min-similarity-lines=4
    ignore-comments=yes
    ignore-docstrings=yes
    ignore-imports=no
    spelling-dict=
    spelling-ignore-words=
    spelling-private-dict-file=
    spelling-store-unknown-words=no
    notes=FIXME,XXX,TODO
    bad-functions=map,filter,input
    good-names=i,j,k,ex,Run,_
    bad-names=foo,bar,baz,toto,tutu,tata
    name-group=
    include-naming-hint=no
    function-rgx=[a-z_][a-z0-9_]{2,30}$
    function-name-hint=[a-z_][a-z0-9_]{2,30}$
    variable-rgx=[a-z_][a-z0-9_]{2,30}$
    variable-name-hint=[a-z_][a-z0-9_]{2,30}$
    const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
    const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$
    attr-rgx=[a-z_][a-z0-9_]{2,30}$
    attr-name-hint=[a-z_][a-z0-9_]{2,30}$
    argument-rgx=[a-z_][a-z0-9_]{2,30}$
    argument-name-hint=[a-z_][a-z0-9_]{2,30}$
    class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
    class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
    inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
    inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$
    class-rgx=[A-Z_][a-zA-Z0-9]+$
    class-name-hint=[A-Z_][a-zA-Z0-9]+$
    module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
    module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
    method-rgx=[a-z_][a-z0-9_]{2,30}$
    method-name-hint=[a-z_][a-z0-9_]{2,30}$
    no-docstring-rgx=^_
    docstring-min-length=-1
    max-nested-blocks=5
    deprecated-modules=regsub,TERMIOS,Bastion,rexec
    import-graph=
    ext-import-graph=
    int-import-graph=
    max-args=5
    ignored-argument-names=_.*
    max-locals=15
    max-returns=6
    max-branches=12
    max-statements=50
    max-parents=13
    max-attributes=7
    min-public-methods=2
    max-public-methods=20
    max-bool-expr=5
    defining-attr-methods=__init__,__new__,setUp
    valid-classmethod-first-arg=cls
    valid-metaclass-classmethod-first-arg=mcs
    exclude-protected=_asdict,_fields,_replace,_source,_make
    overgeneral-exceptions=Exception
    
  3. sebastian-code commented on Jan 10, 2018

    @sebastian-code
    Author

    I tried defining the "python.linting.pylintArgs": [] in the configuration file, but every time I add any of those flags, the linting stops working.

  4. added
    bugIssue identified by VS Code Team member as probable bug
    feature-requestRequest for new features or functionality
    and removed
    bugIssue identified by VS Code Team member as probable bug
    on Jan 10, 2018
  5. brettcannon commented on Jan 10, 2018

    @brettcannon
    Member

    Sebastian Reyes Espinosa (@sebastian-code) so the issue is python.linting.pylintArgs: ["--rcfile=setup.cfg"] doesn't work when defined in one of your settings.json files?

    Basically I'm trying to determine if there's a bug here or if you're asking we provide our own search algorithm for configuration files since Pylint itself only looks for a pylintrc file? (We currently don't do anything special at the moment, BTW.)

  6. sebastian-code commented on Jan 10, 2018

    @sebastian-code
    Author

    To be honest, at this point I'm a little bit out of my league, so my question would be more of the likes of how I make it work?

  7. sebastian-code commented on Jan 10, 2018

    @sebastian-code
    Author

    Ok, now i found it, well, actually it founded me, the issue is than it doesn't work right away but you need to restart to make it work (or wait a really long time, that works too). Thanks for your time, and I'm sorry I kept you busy with it.

  8. brettcannon commented on Jan 10, 2018

    @brettcannon
    Member

    No problem! We're just glad you got it working.

  9. locked as resolved and limited conversation to collaborators on Jul 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-lintingfeature-requestRequest for new features or functionalityinfo-neededIssue requires more information from poster

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions