mirror of
https://github.com/bndr/pipreqs.git
synced 2025-06-06 03:25:21 +00:00
fix(pipreqs): line parsing with comments on the same line
This commit is contained in:
parent
3ed746a5d9
commit
496b729309
@ -38,7 +38,7 @@ def get_all_imports(path):
|
||||
candidates += [os.path.splitext(fn)[0] for fn in files]
|
||||
for file_name in files:
|
||||
with open(os.path.join(root, file_name), "r") as f:
|
||||
lines = filter(filter_line, map(lambda l: l.strip(), f))
|
||||
lines = filter(filter_line, map(lambda l: l.partition("#")[0].strip(), f))
|
||||
for line in lines:
|
||||
if "(" in line:
|
||||
break
|
||||
|
@ -1,3 +1,15 @@
|
||||
"""unused import"""
|
||||
# pylint: disable=undefined-all-variable, import-error, no-absolute-import, too-few-public-methods, missing-docstring
|
||||
import xml.etree # [unused-import]
|
||||
import xml.sax # [unused-import]
|
||||
import os.path as test # [unused-import]
|
||||
from sys import argv as test2 # [unused-import]
|
||||
from sys import flags # [unused-import]
|
||||
# +1:[unused-import,unused-import]
|
||||
from collections import deque, OrderedDict, Counter
|
||||
import requests # [unused-import]
|
||||
# All imports above should be ignored
|
||||
|
||||
import atexit
|
||||
from __future__ import print_function
|
||||
from docopt import docopt
|
||||
@ -9,11 +21,10 @@ import time
|
||||
import sys
|
||||
import signal
|
||||
import bs4
|
||||
import requests
|
||||
import nonexistendmodule
|
||||
import boto as b, import peewee as p,
|
||||
# import django
|
||||
import flask.ext.somext
|
||||
import flask.ext.somext # # #
|
||||
from sqlalchemy import model
|
||||
try:
|
||||
import ujson as json
|
||||
|
Loading…
x
Reference in New Issue
Block a user