wistful / SublimeAutoPEP8

Automatically formats Python code to conform to the PEP 8 style guide using autopep8 and pep8 modules
144 stars 23 forks source link

monkey.patch_all() will auto after import moudules #64

Closed hbh112233abc closed 5 years ago

hbh112233abc commented 5 years ago

monkey.patch_all() will auto after import moudules,but monkey recommend set monkey.patch_all() before import moudules.

import gevent
from gevent import monkey
monkey.patch_all()

from gevent.queue import Queue
import signal
import json
import time
import mysql.connector
import mysql.connector.locales.eng.client_error
from pymongo import *
import gridfs
import os
import uuid
from bson.objectid import ObjectId
import zipfile
from log_config import *
import copy
import PyPDF2
import sys
from weight import Weight
from reports import *
from helper import *
import redis
from socket_client import socket_send
import traceback
from cacheout import Cache
import shutil
import win32api
....

but autopep8 set below

import win32api
import shutil
from cacheout import Cache
import traceback
from socket_client import socket_send
import redis
from helper import *
from reports import *
from weight import Weight
import sys
import PyPDF2
import copy
from log_config import *
import zipfile
from bson.objectid import ObjectId
import uuid
import os
import gridfs
from pymongo import *
import mysql.connector.locales.eng.client_error
import mysql.connector
import time
import json
import signal
from gevent.queue import Queue
import gevent
from gevent import monkey
monkey.patch_all()
...

MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors, including RecursionError on Python 3.6. It may also silently lead to incorrect behaviour on Python 3.7. Please monkey-patch earlier. See https://github.com/gevent/gevent/issues/1016. Modules that had direct imports (NOT patched): ['pymongo.ssl_support (D:\Python\Python37\lib\site-packages\pymongo\ssl_support.py)'].

wistful commented 5 years ago

autopep8 formats without knowing the logic behind imported modules. Do otherwise would make the tool way more complicated.