Giter VIP home page Giter VIP logo

pylint-requests's Introduction

pylint-requests

pypi Python: 3.7+ Downloads Build Status Code coverage License: MIT Code style: black

Description

A pylint plugin to check for common issues with usage of requests.

Currently the following errors are reported:

  • F7801 (requests-not-available)
    Reported if this plugin failed to import requests. This means that: (a) you are running pylint with incorrect PYTHONPATH, (b) you forgot to install requests, or (c) you aren't using requests and don't need the plugin.
  • E7801 (request-without-timeout)
    Reported if a HTTP call (e.g. requests.get) without a timeout is detected.

Installation

pip install pylint-requests

Usage

Use pylint's --load-plugins option to enable the plugin:

pylint --load-plugins=pylint_requests <your_code>

For developers

Install deps and setup pre-commit hook

make init

Run linters, autoformat, tests etc.

make format lint test

Bump new version

make bump_major
make bump_minor
make bump_patch

License

MIT

Change Log

Unreleased

  • require at least Python 3.8.1

0.1.1 - 2020-05-07

  • fix crash with AttributeInferenceError on optional function parameters

0.1.0 - 2019-04-14

  • initial

pylint-requests's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

djeer

pylint-requests's Issues

Plugin Failing to Load

Bug report

What's wrong

I successfully installed this package using pip install pylint-requests but when I run:
pylint --load-plugins=pylint-requests /workspaces/codespaces-blank/test.py

I get the following error:
`@deadex-ng โžœ /workspaces/codespaces-blank/files $ pylint --load-plugins=pylint-requests /workspaces/codespaces-blank/test.py
************* Module Command line or configuration file
Command line or configuration file:1:0: E0013: Plugin 'pylint-requests' is impossible to load, is it installed ? ('No module named 'pylint-requests'') (bad-plugin-value)
************* Module test
/workspaces/codespaces-blank/test.py:3:0: C0303: Trailing whitespace (trailing-whitespace)
/workspaces/codespaces-blank/test.py:4:0: C0304: Final newline missing (missing-final-newline)
/workspaces/codespaces-blank/test.py:1:0: C0114: Missing module docstring (missing-module-docstring)


Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)

@deadex-ng โžœ /workspaces/codespaces-blank/files $ `

How it should work

The pylint-requests plugin should be able load with no errors.

System information

  • Operating system: Ubuntu 20.04.6 LTS (Focal Fossa)
  • Python version: Python 3.10.4
  • pylint version: pylint 2.17.3
  • pylint-requests version: 0.1.1

Linter crashes with astroid AttributeInferenceError

  • Operating System: MacOS 10.15
  • Python version: 3.8
  • pylint-requests version used: 0.1.0

Description

I have a problem with pylint-requests crashing in 1500 lines python file. I've tries to run in PyCharm debugger, but i have an error __main__.py: error: no such option: --multiproc. I don't know how to reproduce this bug without pasting 1500 lines of our code. Posting it here so maybe someone else will be able to reproduce it. For now I've forked this project to our private repo and added try-except to ignore astroid.exceptions.AttributeInferenceError (it fails at one file only).

What I Did

Traceback (most recent call last):
  File "/usr/local/Cellar/[email protected]/3.8.2/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/Cellar/[email protected]/3.8.2/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/user/company/app_name/venv/lib/python3.8/site-packages/pylint/__main__.py", line 18, in <module>
    pylint.run_pylint()
  File "/Users/user/company/app_name/venv/lib/python3.8/site-packages/pylint/__init__.py", line 22, in run_pylint
    PylintRun(sys.argv[1:])
  File "/Users/user/company/app_name/venv/lib/python3.8/site-packages/pylint/lint/run.py", line 338, in __init__
    linter.check(args)
  File "/Users/user/company/app_name/venv/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 870, in check
    self._check_files(
  File "/Users/user/company/app_name/venv/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 904, in _check_files
    self._check_file(get_ast, check_astroid_module, name, filepath, modname)
  File "/Users/user/company/app_name/venv/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 930, in _check_file
    check_astroid_module(ast_node)
  File "/Users/user/company/app_name/venv/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1062, in check_astroid_module
    retval = self._check_astroid_module(
  File "/Users/user/company/app_name/venv/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1107, in _check_astroid_module
    walker.walk(ast_node)
  File "/Users/user/company/app_name/venv/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 75, in walk
    self.walk(child)
  File "/Users/user/company/app_name/venv/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 75, in walk
    self.walk(child)
  File "/Users/user/company/app_name/venv/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 75, in walk
    self.walk(child)
  [Previous line repeated 2 more times]
  File "/Users/user/company/app_name/venv/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 72, in walk
    callback(astroid)
  File "/Users/user/company/app_name/venv/lib/python3.8/site-packages/pylint_requests/checkers/timeout.py", line 26, in visit_call
    if not is_requests_func(node.func):
  File "/Users/user/company/app_name/venv/lib/python3.8/site-packages/pylint_requests/utils.py", line 121, in is_requests_func
    ) or is_requests_session(node.expr):
  File "/Users/user/company/app_name/venv/lib/python3.8/site-packages/pylint_requests/utils.py", line 84, in is_requests_session
    assigns = _lookup(node)
  File "/Users/user/company/app_name/venv/lib/python3.8/site-packages/pylint_requests/utils.py", line 65, in _lookup
    return obj.getattr(node.attrname)
  File "/Users/user/company/app_name/venv/lib/python3.8/site-packages/astroid/bases.py", line 190, in getattr
    return self._proxied.getattr(name, context, class_context=False)
  File "/Users/user/company/app_name/venv/lib/python3.8/site-packages/astroid/scoped_nodes.py", line 2455, in getattr
    raise exceptions.AttributeInferenceError(
astroid.exceptions.AttributeInferenceError: 'META' not found on <ClassDef.NoneType l.0 at 0x10dc9ca30>.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.