Skip to content

Conversation

@memst
Copy link
Contributor

@memst memst commented Sep 13, 2021

Isort 5.0.0 has been released over a year ago and many options have been deprecated as they are now the default behaviour.

Current command for isort in CONTRIBUTING.md causes an error:

isort: error: unrecognized arguments: h11 bench examples fuzz

The PR removes all arguments that are unnecessary in the current version.

If support for the old versoin of isort is still needed, a compromise can be reached by using the command:

$ isort --apply --settings-path setup.cfg --recursive h11 bench examples fuzz

In that case the old version will work but skip the __init__.py file, and the new version will work but give deprecation warnings.

Copy link
Contributor

@lovelydinosaur lovelydinosaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems legit to me. Anyone else have an issue with this?

force_grid_wrap=0
include_trailing_comma=True
known_first_party=h11, test
known_third_party=pytest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't these still valid and useful?

Copy link
Contributor Author

@memst memst Sep 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're now unnecessary as any imports from the directories that isort is sorting will be considered first party. The options can be left but they will serve no function.

Let me know if you want me to remove them.

@pquentin
Copy link

@memst Would it be easier to just use isort --profile black and remove all other settings?

@memst
Copy link
Contributor Author

memst commented Sep 14, 2021

Removing all of the config could be a good idea. The only option that currently does something for the repository and isn't included in --profile black is order_by_type

order_by_type: If set to true - isort will create separate sections within "from" imports for CONSTANTS, Classes, and modules/functions. (reference)

Currently false:

from typing import Any, cast, Dict, List, Tuple, Union

Black (also default) true:

from typing import Any, Dict, List, Tuple, Union, cast
Complete diff with `--profile Black`:
diff --git a/h11/_connection.py b/h11/_connection.py
index bcd3089..4140de0 100644
--- a/h11/_connection.py
+++ b/h11/_connection.py
@@ -9,8 +9,8 @@ from ._state import *  # Import all state sentinels
 from ._state import _SWITCH_CONNECT, _SWITCH_UPGRADE, ConnectionState
 from ._util import (  # Import the internal things we need
     LocalProtocolError,
-    make_sentinel,
     RemoteProtocolError,
+    make_sentinel,
 )
 from ._writers import WRITERS
 
diff --git a/h11/_events.py b/h11/_events.py
index ebbf10f..1103898 100644
--- a/h11/_events.py
+++ b/h11/_events.py
@@ -8,11 +8,11 @@
 import re
 from abc import ABC
 from dataclasses import dataclass, field
-from typing import Any, cast, Dict, List, Tuple, Union
+from typing import Any, Dict, List, Tuple, Union, cast
 
 from ._abnf import request_target
 from ._headers import Headers, normalize_and_validate
-from ._util import bytesify, LocalProtocolError, validate
+from ._util import LocalProtocolError, bytesify, validate
 
 # Everything in __all__ gets re-exported as part of the h11 public API.
 __all__ = [
diff --git a/h11/_headers.py b/h11/_headers.py
index e8f24d6..4bcf0ea 100644
--- a/h11/_headers.py
+++ b/h11/_headers.py
@@ -2,7 +2,7 @@ import re
 from collections.abc import Sequence
 
 from ._abnf import field_name, field_value
-from ._util import bytesify, LocalProtocolError, validate
+from ._util import LocalProtocolError, bytesify, validate
 
 # Facts
 # -----
diff --git a/h11/tests/test_connection.py b/h11/tests/test_connection.py
index de175de..e7d5d9a 100644
--- a/h11/tests/test_connection.py
+++ b/h11/tests/test_connection.py
@@ -1,6 +1,6 @@
 import pytest
 
-from .._connection import _body_framing, _keep_alive, Connection, NEED_DATA, PAUSED
+from .._connection import NEED_DATA, PAUSED, Connection, _body_framing, _keep_alive
 from .._events import *
 from .._state import *
 from .._util import LocalProtocolError, RemoteProtocolError
diff --git a/h11/tests/test_io.py b/h11/tests/test_io.py
index 459a627..dec98e6 100644
--- a/h11/tests/test_io.py
+++ b/h11/tests/test_io.py
@@ -3,23 +3,23 @@ import pytest
 from .._events import *
 from .._headers import Headers, normalize_and_validate
 from .._readers import (
-    _obsolete_line_fold,
+    READERS,
     ChunkedReader,
     ContentLengthReader,
     Http10Reader,
-    READERS,
+    _obsolete_line_fold,
 )
 from .._receivebuffer import ReceiveBuffer
 from .._state import *
 from .._util import LocalProtocolError
 from .._writers import (
+    WRITERS,
     ChunkedWriter,
     ContentLengthWriter,
     Http10Writer,
     write_any_response,
     write_headers,
     write_request,
-    WRITERS,
 )
 from .helpers import normalize_data_events

The option can be added through commandline (--dt = --dont-order-by-type):

isort --profile black --dt h11 bench examples fuzz

Other settings that would change, but don't impact the current code:

combine_as_imports=True
no_lines_before=LOCALFOLDER

@memst memst force-pushed the update-contributing branch from 949d06f to b9f99b9 Compare September 14, 2021 11:00
Copy link

@pquentin pquentin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! (But you'll need an approval from someone on the python-hyper org)

@pgjones
Copy link
Member

pgjones commented Sep 14, 2021

I think you also need to update the tox isort command.

@pgjones pgjones merged commit f643a8e into python-hyper:master Sep 14, 2021
@pgjones
Copy link
Member

pgjones commented Sep 14, 2021

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants