Skip to content

[WIP] add isort to CI #291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions matrix_client/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@

import json
import warnings
from requests import Session, RequestException
from time import time, sleep
from .__init__ import __version__
from .errors import MatrixError, MatrixRequestError, MatrixHttpLibError
from urllib3.util import parse_url
from time import sleep, time

from requests import RequestException, Session
from urllib3.exceptions import LocationParseError
from urllib3.util import parse_url

from .__init__ import __version__
from .errors import MatrixError, MatrixHttpLibError, MatrixRequestError

try:
from urllib import quote
Expand Down
14 changes: 8 additions & 6 deletions matrix_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,23 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
import sys
from threading import Thread
from time import sleep
from uuid import uuid4
from warnings import warn

from .api import MatrixHttpApi
from .errors import MatrixRequestError, MatrixUnexpectedResponse
from .room import Room
from .user import User

try:
from .crypto.olm_device import OlmDevice
ENCRYPTION_SUPPORT = True
except ImportError:
ENCRYPTION_SUPPORT = False
from threading import Thread
from time import sleep
from uuid import uuid4
from warnings import warn
import logging
import sys

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion matrix_client/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
from uuid import uuid4

from .checks import check_room_id
from .user import User
from .errors import MatrixRequestError
from .user import User


class Room(object):
Expand Down
6 changes: 3 additions & 3 deletions samples/ChangeDisplayName.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
# 11 - Serverside Error

import sys
import samples_common

from matrix_client.client import MatrixClient
from matrix_client.api import MatrixRequestError
import samples_common
from requests.exceptions import MissingSchema

from matrix_client.api import MatrixRequestError
from matrix_client.client import MatrixClient

host, username, password = samples_common.get_user_details(sys.argv)

Expand Down
5 changes: 3 additions & 2 deletions samples/GetUserProfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@


import sys

import samples_common # Common bits used between samples
from requests.exceptions import MissingSchema

from matrix_client.client import MatrixClient
from matrix_client.api import MatrixRequestError
from requests.exceptions import MissingSchema
from matrix_client.client import MatrixClient

host, username, password = samples_common.get_user_details(sys.argv)

Expand Down
6 changes: 3 additions & 3 deletions samples/SetRoomProfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
# 11 - Serverside Error

import sys
import samples_common

from matrix_client.client import MatrixClient
from matrix_client.api import MatrixRequestError
import samples_common
from requests.exceptions import MissingSchema

from matrix_client.api import MatrixRequestError
from matrix_client.client import MatrixClient

host, username, password = samples_common.get_user_details(sys.argv)

Expand Down
7 changes: 4 additions & 3 deletions samples/SimpleChatClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
# 11 - Wrong room format.
# 12 - Couldn't find room.

import logging
import sys

import samples_common # Common bits used between samples
import logging
from requests.exceptions import MissingSchema

from matrix_client.client import MatrixClient
from matrix_client.api import MatrixRequestError
from requests.exceptions import MissingSchema
from matrix_client.client import MatrixClient


# Called when a message is recieved.
Expand Down
6 changes: 4 additions & 2 deletions samples/UserPassOrTokenClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
"""

import argparse
from matrix_client.client import MatrixClient

from requests.exceptions import InvalidSchema, MissingSchema

from matrix_client.api import MatrixRequestError
from requests.exceptions import MissingSchema, InvalidSchema
from matrix_client.client import MatrixClient


def example(host, user, password, token):
Expand Down
13 changes: 12 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,15 @@ addopts = test/
universal = 1

[metadata]
license_file = LICENSE
license_file = LICENSE

[isort]
line_length = 89
not_skip = __init__.py
sections=FUTURE,STDLIB,COMPAT,THIRDPARTY,TWISTED,FIRSTPARTY,TESTS,LOCALFOLDER
default_section=THIRDPARTY
known_first_party = matrix_client
known_tests=tests
multi_line_output=3
include_trailing_comma=true
combine_as_imports=true
13 changes: 8 additions & 5 deletions test/api_test.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import responses
import pytest
import json
from copy import deepcopy
from matrix_client import client, api
from matrix_client.errors import MatrixRequestError, MatrixError, MatrixHttpLibError
from matrix_client import __version__ as lib_version

import pytest
import responses

from matrix_client import __version__ as lib_version, api, client
from matrix_client.errors import MatrixError, MatrixHttpLibError, MatrixRequestError

from . import response_examples

MATRIX_V2_API_PATH = "/_matrix/client/r0"


Expand Down
10 changes: 7 additions & 3 deletions test/client_test.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import pytest
import responses
import json
from copy import deepcopy
from matrix_client.client import MatrixClient, Room, User, CACHE

import pytest
import responses

from matrix_client.api import MATRIX_V2_API_PATH
from matrix_client.client import CACHE, MatrixClient, Room, User

from . import response_examples

try:
from urllib import quote
except ImportError:
Expand Down
8 changes: 4 additions & 4 deletions test/crypto/olm_device_test.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import pytest
pytest.importorskip("olm") # noqa

import json
from copy import deepcopy
from test.response_examples import example_key_upload_response

import pytest
import responses

from matrix_client.api import MATRIX_V2_API_PATH
from matrix_client.client import MatrixClient
from matrix_client.crypto.olm_device import OlmDevice
from test.response_examples import example_key_upload_response

pytest.importorskip("olm") # noqa

HOSTNAME = 'http://example.com'

Expand Down
7 changes: 6 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py27,py34,py35,py36,packaging,pep8,docs
envlist = py27,py34,py35,py36,packaging,pep8,docs,check_isort

[testenv]
passenv = TRAVIS TRAVIS_*
Expand Down Expand Up @@ -33,6 +33,11 @@ deps = .[doc]
changedir = docs
commands = sphinx-build -W source build/html

[testenv:check_isort]
skip_install = True
deps = isort
commands = /bin/sh -c "isort -c -sp setup.cfg -rc matrix_client samples test"

[travis]
python =
2.7: py27
Expand Down