Merge d49ba8230179e371aef76d4b15ffdde9c8296286 into 68f9b2859d45a60e699839f87b1b9558cd36a329

This commit is contained in:
Kuldeep Khatke 2023-10-30 16:46:28 -03:00 committed by GitHub
commit 08a25445e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 193 additions and 160 deletions

View File

@ -1,65 +1,67 @@
"""unused import""" """unused import"""
# pylint: disable=undefined-all-variable, import-error, no-absolute-import, too-few-public-methods, missing-docstring # pylint: disable=undefined-all-variable, import-error, no-absolute-import
# pylint: disable=too-few-public-methods, missing-docstring
from __future__ import print_function # noqa:F401
import xml.etree # [unused-import] import xml.etree # [unused-import]
import xml.sax # [unused-import] import xml.sax # noqa:F401 # [unused-import]
import os.path as test # [unused-import] import os.path as test # noqa:F401 # [unused-import]
from sys import argv as test2 # [unused-import] from sys import argv as test2 # noqa:F401 # [unused-import]
from sys import flags # [unused-import] from sys import flags # noqa:F401 # [unused-import]
# +1:[unused-import,unused-import] # +1:[unused-import,unused-import]
from collections import deque, OrderedDict, Counter from collections import deque, OrderedDict, Counter # noqa:F401
# All imports above should be ignored # All imports above should be ignored
import requests # [unused-import] import requests # noqa:F401 # [unused-import]
# setuptools # setuptools
import zipimport # command/easy_install.py import zipimport # command/easy_install.py
# twisted # twisted
from importlib import invalidate_caches # python/test/test_deprecate.py from importlib import invalidate_caches # noqa:F401, E501 # python/test/test_deprecate.py
# astroid # astroid
import zipimport # manager.py import zipimport # noqa:F401, F811 # manager.py
# IPython # IPython
from importlib.machinery import all_suffixes # core/completerlib.py from importlib.machinery import all_suffixes # noqa:F401, E501 # core/completerlib.py
import importlib # html/notebookapp.py import importlib # noqa:F401 # html/notebookapp.py
from IPython.utils.importstring import import_item # Many files from IPython.utils.importstring import import_item # noqa:F401 # Many files
# pyflakes # pyflakes
# test/test_doctests.py # test/test_doctests.py
from pyflakes.test.test_imports import Test as TestImports from pyflakes.test.test_imports import Test as TestImports # noqa:F401
# Nose # Nose
from nose.importer import Importer, add_path, remove_path # loader.py from nose.importer import Importer, add_path, remove_path # noqa:F401, E501 # loader.py
# see issue #88 # see issue #88
import analytics import analytics # noqa:F401
import flask_seasurf import flask_seasurf # noqa:F401
import atexit import atexit # noqa:F401
from __future__ import print_function from docopt import docopt # noqa:F401
from docopt import docopt import curses, logging, sqlite3 # noqa:F401, E401
import curses, logging, sqlite3 import logging # noqa:F401, F811
import logging import os # noqa:F401
import os import sqlite3 # noqa:F401, F811
import sqlite3 import time # noqa:F401
import time import sys # noqa:F401
import sys import signal # noqa:F401
import signal import bs4 # noqa:F401
import bs4 import nonexistendmodule # noqa:F401
import nonexistendmodule import boto as b, peewee as p # noqa:F401, E401
import boto as b, peewee as p
# import django # import django
import flask.ext.somext # # # import flask.ext.somext # noqa:F401 # # #
from sqlalchemy import model from sqlalchemy import model # noqa:F401
try: try:
import ujson as json import ujson as json
except ImportError: except ImportError:
import json import json # noqa:F401
import models import models # noqa:F401
def main(): def main():
pass pass
import after_method_is_valid_even_if_not_pep8
import after_method_is_valid_even_if_not_pep8 # noqa:F401, E402

View File

@ -1,65 +1,67 @@
"""unused import""" """unused import"""
# pylint: disable=undefined-all-variable, import-error, no-absolute-import, too-few-public-methods, missing-docstring # pylint: disable=undefined-all-variable, import-error, no-absolute-import
# pylint: disable=too-few-public-methods, missing-docstring
from __future__ import print_function # noqa:F401
import xml.etree # [unused-import] import xml.etree # [unused-import]
import xml.sax # [unused-import] import xml.sax # noqa:F401 # [unused-import]
import os.path as test # [unused-import] import os.path as test # noqa:F401 # [unused-import]
from sys import argv as test2 # [unused-import] from sys import argv as test2 # noqa:F401 # [unused-import]
from sys import flags # [unused-import] from sys import flags # noqa:F401 # [unused-import]
# +1:[unused-import,unused-import] # +1:[unused-import,unused-import]
from collections import deque, OrderedDict, Counter from collections import deque, OrderedDict, Counter # noqa:F401
# All imports above should be ignored # All imports above should be ignored
import requests # [unused-import] import requests # noqa:F401 # [unused-import]
# setuptools # setuptools
import zipimport # command/easy_install.py import zipimport # command/easy_install.py
# twisted # twisted
from importlib import invalidate_caches # python/test/test_deprecate.py from importlib import invalidate_caches # noqa:F401, E501 # python/test/test_deprecate.py
# astroid # astroid
import zipimport # manager.py import zipimport # noqa:F401, F811 # manager.py
# IPython # IPython
from importlib.machinery import all_suffixes # core/completerlib.py from importlib.machinery import all_suffixes # noqa:F401, E501 # core/completerlib.py
import importlib # html/notebookapp.py import importlib # noqa:F401 # html/notebookapp.py
from IPython.utils.importstring import import_item # Many files from IPython.utils.importstring import import_item # noqa:F401 # Many files
# pyflakes # pyflakes
# test/test_doctests.py # test/test_doctests.py
from pyflakes.test.test_imports import Test as TestImports from pyflakes.test.test_imports import Test as TestImports # noqa:F401
# Nose # Nose
from nose.importer import Importer, add_path, remove_path # loader.py from nose.importer import Importer, add_path, remove_path # noqa:F401, E501 # loader.py
# see issue #88 # see issue #88
import analytics import analytics # noqa:F401
import flask_seasurf import flask_seasurf # noqa:F401
import atexit import atexit # noqa:F401
from __future__ import print_function from docopt import docopt # noqa:F401
from docopt import docopt import curses, logging, sqlite3 # noqa:F401, E401
import curses, logging, sqlite3 import logging # noqa:F401, F811
import logging import os # noqa:F401
import os import sqlite3 # noqa:F401, F811
import sqlite3 import time # noqa:F401
import time import sys # noqa:F401
import sys import signal # noqa:F401
import signal import bs4 # noqa:F401
import bs4 import nonexistendmodule # noqa:F401
import nonexistendmodule import boto as b, peewee as p # noqa:F401, E401
import boto as b, peewee as p
# import django # import django
import flask.ext.somext # # # import flask.ext.somext # noqa:F401 # # #
# from sqlalchemy import model from sqlalchemy import model # noqa:F401
try: try:
import ujson as json import ujson as json
except ImportError: except ImportError:
import json import json # noqa:F401
import models import models # noqa:F401
def main(): def main():
pass pass
import after_method_is_valid_even_if_not_pep8
import after_method_is_valid_even_if_not_pep8 # noqa:F401, E402

View File

@ -1,5 +1,5 @@
import pymongo import pymongo # noqa:F401
from bson.objectid import ObjectId from bson.objectid import ObjectId # noqa:F401
# 'bson' package is mapped to 'pymongo'. # 'bson' package is mapped to 'pymongo'.
# But running pipreqs should not result in two duplicated # But running pipreqs should not result in two duplicated

View File

@ -1,2 +1,2 @@
# Everything in here should be ignored # Everything in here should be ignored
from pattern.web import Twitter, plaintext from pattern.web import Twitter, plaintext # noqa:F401

View File

@ -1,2 +1,2 @@
# Everything in here should be ignored # Everything in here should be ignored
import click import click # noqa:F401

View File

@ -1,61 +1,63 @@
"""unused import""" """unused import"""
# pylint: disable=undefined-all-variable, import-error, no-absolute-import, too-few-public-methods, missing-docstring # pylint: disable=undefined-all-variable, import-error, no-absolute-import
# pylint: disable=too-few-public-methods, missing-docstring
from __future__ import print_function # noqa:F401
import xml.etree # [unused-import] import xml.etree # [unused-import]
import xml.sax # [unused-import] import xml.sax # noqa:F401 # [unused-import]
import os.path as test # [unused-import] import os.path as test # noqa:F401 # [unused-import]
from sys import argv as test2 # [unused-import] from sys import argv as test2 # noqa:F401 # [unused-import]
from sys import flags # [unused-import] from sys import flags # noqa:F401 # [unused-import]
# +1:[unused-import,unused-import] # +1:[unused-import,unused-import]
from collections import deque, OrderedDict, Counter from collections import deque, OrderedDict, Counter # noqa:F401
# All imports above should be ignored # All imports above should be ignored
import requests # [unused-import] import requests # noqa:F401 # [unused-import]
# setuptools # setuptools
import zipimport # command/easy_install.py import zipimport # command/easy_install.py
# twisted # twisted
from importlib import invalidate_caches # python/test/test_deprecate.py from importlib import invalidate_caches # noqa:F401, E501 # python/test/test_deprecate.py
# astroid # astroid
import zipimport # manager.py import zipimport # noqa:F401, F811 # manager.py
# IPython # IPython
from importlib.machinery import all_suffixes # core/completerlib.py from importlib.machinery import all_suffixes # noqa:F401, E501 # core/completerlib.py
import importlib # html/notebookapp.py import importlib # noqa:F401 # html/notebookapp.py
from IPython.utils.importstring import import_item # Many files from IPython.utils.importstring import import_item # noqa:F401 # Many files
# pyflakes # pyflakes
# test/test_doctests.py # test/test_doctests.py
from pyflakes.test.test_imports import Test as TestImports from pyflakes.test.test_imports import Test as TestImports # noqa:F401
# Nose # Nose
from nose.importer import Importer, add_path, remove_path # loader.py from nose.importer import Importer, add_path, remove_path # noqa:F401, E501 # loader.py
import atexit import atexit # noqa:F401
from __future__ import print_function from docopt import docopt # noqa:F401
from docopt import docopt import curses, logging, sqlite3 # noqa:F401, E401
import curses, logging, sqlite3 import logging # noqa:F401, F811
import logging import os # noqa:F401
import os import sqlite3 # noqa:F401, F811
import sqlite3 import time # noqa:F401
import time import sys # noqa:F401
import sys import signal # noqa:F401
import signal import bs4 # noqa:F401
import bs4 import nonexistendmodule # noqa:F401
import nonexistendmodule import boto as b, peewee as p # noqa:F401, E401
import boto as b, peewee as p
# import django # import django
import flask.ext.somext # # # import flask.ext.somext # noqa:F401 # # #
from sqlalchemy import model from sqlalchemy import model # noqa:F401
try: try:
import ujson as json import ujson as json
except ImportError: except ImportError:
import json import json # noqa:F401
import models import models # noqa:F401
def main(): def main():
pass pass
import after_method_is_valid_even_if_not_pep8
import after_method_is_valid_even_if_not_pep8 # noqa:F401, E402

View File

@ -1 +1 @@
import boto as b, import peewee as p, import boto as b, import peewee as p, # noqa:E401, E999

View File

@ -113,9 +113,11 @@ class TestPipreqs(unittest.TestCase):
""" """
Test that all modules we will test upon are in requirements file Test that all modules we will test upon are in requirements file
""" """
pipreqs.init({'<path>': self.project, '--savepath': None, '--print': False, pipreqs.init({
'--use-local': None, '--force': True, '--proxy':None, '--pypi-server':None, '<path>': self.project, '--savepath': None, '--print': False,
'--diff': None, '--clean': None, '--mode': None}) '--use-local': None, '--force': True, '--proxy': None,
'--pypi-server': None, '--diff': None, '--clean': None,
'--mode': None})
assert os.path.exists(self.requirements_path) == 1 assert os.path.exists(self.requirements_path) == 1
with open(self.requirements_path, "r") as f: with open(self.requirements_path, "r") as f:
data = f.read().lower() data = f.read().lower()
@ -130,9 +132,11 @@ class TestPipreqs(unittest.TestCase):
Test that items listed in requirements.text are the same Test that items listed in requirements.text are the same
as locals expected as locals expected
""" """
pipreqs.init({'<path>': self.project, '--savepath': None, '--print': False, pipreqs.init({
'--use-local': True, '--force': True, '--proxy':None, '--pypi-server':None, '<path>': self.project, '--savepath': None, '--print': False,
'--diff': None, '--clean': None, '--mode': None}) '--use-local': True, '--force': True, '--proxy': None,
'--pypi-server': None, '--diff': None, '--clean': None,
'--mode': None})
assert os.path.exists(self.requirements_path) == 1 assert os.path.exists(self.requirements_path) == 1
with open(self.requirements_path, "r") as f: with open(self.requirements_path, "r") as f:
data = f.readlines() data = f.readlines()
@ -145,9 +149,10 @@ class TestPipreqs(unittest.TestCase):
Test that we can save requirements.txt correctly Test that we can save requirements.txt correctly
to a different path to a different path
""" """
pipreqs.init({'<path>': self.project, '--savepath': self.alt_requirement_path, pipreqs.init({
'--use-local': None, '--proxy':None, '--pypi-server':None, '--print': False, '<path>': self.project, '--savepath': self.alt_requirement_path,
'--diff': None, '--clean': None, '--mode': None}) '--use-local': None, '--proxy': None, '--pypi-server': None,
'--print': False, '--diff': None, '--clean': None, '--mode': None})
assert os.path.exists(self.alt_requirement_path) == 1 assert os.path.exists(self.alt_requirement_path) == 1
with open(self.alt_requirement_path, "r") as f: with open(self.alt_requirement_path, "r") as f:
data = f.read().lower() data = f.read().lower()
@ -163,9 +168,11 @@ class TestPipreqs(unittest.TestCase):
""" """
with open(self.requirements_path, "w") as f: with open(self.requirements_path, "w") as f:
f.write("should_not_be_overwritten") f.write("should_not_be_overwritten")
pipreqs.init({'<path>': self.project, '--savepath': None, '--use-local': None, pipreqs.init({
'--force': None, '--proxy':None, '--pypi-server':None, '--print': False, '<path>': self.project, '--savepath': None, '--use-local': None,
'--diff': None, '--clean': None, '--mode': None}) '--force': None, '--proxy': None, '--pypi-server': None,
'--print': False, '--diff': None, '--clean': None,
'--mode': None})
assert os.path.exists(self.requirements_path) == 1 assert os.path.exists(self.requirements_path) == 1
with open(self.requirements_path, "r") as f: with open(self.requirements_path, "r") as f:
data = f.read().lower() data = f.read().lower()
@ -203,16 +210,21 @@ class TestPipreqs(unittest.TestCase):
Test --ignore parameter Test --ignore parameter
""" """
pipreqs.init( pipreqs.init(
{'<path>': self.project_with_ignore_directory, '--savepath': None, {
'--print': False, '--use-local': None, '--force': True, '<path>': self.project_with_ignore_directory,
'--proxy':None, '--pypi-server':None, '--savepath': None, '--print': False,
'--ignore':'.ignored_dir,.ignore_second', '--use-local': None, '--force': True,
'--proxy': None, '--pypi-server': None,
'--ignore': '.ignored_dir,.ignore_second',
'--diff': None, '--diff': None,
'--clean': None, '--clean': None,
'--mode': None '--mode': None
} }
) )
with open(os.path.join(self.project_with_ignore_directory, "requirements.txt"), "r") as f: with open(
os.path.join(
self.project_with_ignore_directory, "requirements.txt"
), "r") as f:
data = f.read().lower() data = f.read().lower()
for item in ['click', 'getpass']: for item in ['click', 'getpass']:
self.assertFalse(item.lower() in data) self.assertFalse(item.lower() in data)
@ -230,7 +242,9 @@ class TestPipreqs(unittest.TestCase):
'--mode': 'no-pin' '--mode': 'no-pin'
} }
) )
with open(os.path.join(self.project_with_ignore_directory, "requirements.txt"), "r") as f: with open(os.path.join(
self.project_with_ignore_directory, "requirements.txt"), "r"
) as f:
data = f.read().lower() data = f.read().lower()
for item in ['beautifulsoup4', 'boto']: for item in ['beautifulsoup4', 'boto']:
self.assertTrue(item.lower() in data) self.assertTrue(item.lower() in data)
@ -240,7 +254,9 @@ class TestPipreqs(unittest.TestCase):
Test --mode=gt Test --mode=gt
""" """
pipreqs.init( pipreqs.init(
{'<path>': self.project_with_ignore_directory, '--savepath': None, '--print': False, {
'<path>': self.project_with_ignore_directory,
'--savepath': None, '--print': False,
'--use-local': None, '--force': True, '--use-local': None, '--force': True,
'--proxy': None, '--proxy': None,
'--pypi-server': None, '--pypi-server': None,
@ -249,7 +265,9 @@ class TestPipreqs(unittest.TestCase):
'--mode': 'gt' '--mode': 'gt'
} }
) )
with open(os.path.join(self.project_with_ignore_directory, "requirements.txt"), "r") as f: with open(os.path.join(
self.project_with_ignore_directory, "requirements.txt"), "r"
) as f:
data = f.readlines() data = f.readlines()
for item in data: for item in data:
symbol = '>=' symbol = '>='
@ -261,7 +279,9 @@ class TestPipreqs(unittest.TestCase):
Test --mode=compat Test --mode=compat
""" """
pipreqs.init( pipreqs.init(
{'<path>': self.project_with_ignore_directory, '--savepath': None, '--print': False, {
'<path>': self.project_with_ignore_directory,
'--savepath': None, '--print': False,
'--use-local': None, '--force': True, '--use-local': None, '--force': True,
'--proxy': None, '--proxy': None,
'--pypi-server': None, '--pypi-server': None,
@ -270,7 +290,9 @@ class TestPipreqs(unittest.TestCase):
'--mode': 'compat' '--mode': 'compat'
} }
) )
with open(os.path.join(self.project_with_ignore_directory, "requirements.txt"), "r") as f: with open(os.path.join(
self.project_with_ignore_directory, "requirements.txt"), "r"
) as f:
data = f.readlines() data = f.readlines()
for item in data: for item in data:
symbol = '~=' symbol = '~='
@ -282,14 +304,16 @@ class TestPipreqs(unittest.TestCase):
Test --clean parameter Test --clean parameter
""" """
pipreqs.init( pipreqs.init(
{'<path>': self.project, '--savepath': None, '--print': False, {
'<path>': self.project, '--savepath': None, '--print': False,
'--use-local': None, '--force': True, '--proxy': None, '--use-local': None, '--force': True, '--proxy': None,
'--pypi-server': None, '--diff': None, '--clean': None, '--pypi-server': None, '--diff': None, '--clean': None,
'--mode': None} '--mode': None}
) )
assert os.path.exists(self.requirements_path) == 1 assert os.path.exists(self.requirements_path) == 1
pipreqs.init( pipreqs.init(
{'<path>': self.project, '--savepath': None, '--print': False, {
'<path>': self.project, '--savepath': None, '--print': False,
'--use-local': None, '--force': None, '--proxy': None, '--use-local': None, '--force': None, '--proxy': None,
'--pypi-server': None, '--diff': None, '--pypi-server': None, '--diff': None,
'--clean': self.requirements_path, '--mode': 'non-pin'} '--clean': self.requirements_path, '--mode': 'non-pin'}
@ -305,15 +329,18 @@ class TestPipreqs(unittest.TestCase):
""" """
cleaned_module = 'sqlalchemy' cleaned_module = 'sqlalchemy'
pipreqs.init( pipreqs.init(
{'<path>': self.project, '--savepath': None, '--print': False, {
'<path>': self.project, '--savepath': None, '--print': False,
'--use-local': None, '--force': True, '--proxy': None, '--use-local': None, '--force': True, '--proxy': None,
'--pypi-server': None, '--diff': None, '--clean': None, '--pypi-server': None, '--diff': None, '--clean': None,
'--mode': None} '--mode': None}
) )
assert os.path.exists(self.requirements_path) == 1 assert os.path.exists(self.requirements_path) == 1
modules_clean = [m for m in self.modules if m != cleaned_module] modules_clean = [ # noqa:F841
m for m in self.modules if m != cleaned_module]
pipreqs.init( pipreqs.init(
{'<path>': self.project_clean, '--savepath': None, {
'<path>': self.project_clean, '--savepath': None,
'--print': False, '--use-local': None, '--force': None, '--print': False, '--use-local': None, '--force': None,
'--proxy': None, '--pypi-server': None, '--diff': None, '--proxy': None, '--pypi-server': None, '--diff': None,
'--clean': self.requirements_path, '--mode': 'non-pin'} '--clean': self.requirements_path, '--mode': 'non-pin'}