Skip to content

Commit

Permalink
Merge pull request asdf-format#1518 from braingram/remove_ruff_all
Browse files Browse the repository at this point in the history
limit ruff rules
  • Loading branch information
braingram authored Apr 11, 2023
2 parents 13334ba + 5d73039 commit 9bcdbbe
Show file tree
Hide file tree
Showing 35 changed files with 131 additions and 156 deletions.
2 changes: 1 addition & 1 deletion asdf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from ._types import CustomType
from ._version import version as __version__
from .asdf import AsdfFile
from .asdf import open_asdf as open # noqa: A001
from .asdf import open_asdf as open
from .config import config_context, get_config
from .stream import Stream
from .tags.core import IntegerType
Expand Down
2 changes: 1 addition & 1 deletion asdf/_convenience.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def info(node_or_path, max_rows=DEFAULT_MAX_ROWS, max_cols=DEFAULT_MAX_COLS, sho
"""
with _manage_node(node_or_path) as node:
lines = render_tree(node, max_rows=max_rows, max_cols=max_cols, show_values=show_values, identifier="root")
print("\n".join(lines)) # noqa: T201
print("\n".join(lines))


@contextmanager
Expand Down
2 changes: 1 addition & 1 deletion asdf/_tests/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ def _assert_extension_type_correctness(extension, extension_type, resolver):
try:
with generic_io.get_file(schema_location) as f:
yaml.safe_load(f.read())
except Exception as err: # noqa: BLE001
except Exception as err:
msg = (
f"{extension_type.__name__} supports tag, {check_type.yaml_tag}, "
f"which resolves to schema at {schema_location}, but "
Expand Down
4 changes: 2 additions & 2 deletions asdf/_tests/tags/core/tests/test_ndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ def test_problematic_class_attributes(tmp_path):
assert isinstance(af["arr"], ndarray.NDArrayType)

with pytest.raises(AttributeError, match=r".* object has no attribute 'name'"):
af["arr"].name # noqa: B018
af["arr"].name

with pytest.raises(AttributeError, match=r".* object has no attribute 'version'"):
af["arr"].version # noqa: B018
af["arr"].version
10 changes: 5 additions & 5 deletions asdf/_tests/test_deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_types_module_deprecation():

def test_default_extensions_deprecation():
with pytest.warns(AsdfDeprecationWarning, match="default_extensions is deprecated"):
asdf.extension.default_extensions # noqa: B018
asdf.extension.default_extensions


def test_default_resolver():
Expand All @@ -108,8 +108,8 @@ def test_get_cached_asdf_extension_list_deprecation():

def test_asdf_type_format_tag():
with pytest.warns(AsdfDeprecationWarning, match="asdf.types.format_tag is deprecated"):
asdf._types.format_tag # noqa: B018
asdf.testing.helpers.format_tag # noqa: B018
asdf._types.format_tag
asdf.testing.helpers.format_tag


@pytest.mark.parametrize("name", ["AsdfExtension", "AsdfExtensionList", "BuiltinExtension"])
Expand All @@ -120,7 +120,7 @@ def test_extension_class_deprecation(name):

def test_top_level_asdf_extension_deprecation():
with pytest.warns(AsdfDeprecationWarning, match="AsdfExtension is deprecated"):
asdf.AsdfExtension # noqa: B018
asdf.AsdfExtension


def test_deprecated_entry_point(mock_entry_points): # noqa: F811
Expand All @@ -144,4 +144,4 @@ def test_asdf_tests_helpers_deprecation():
def test_blocks_deprecated():
af = asdf.AsdfFile()
with pytest.warns(AsdfDeprecationWarning, match="The property AsdfFile.blocks has been deprecated"):
af.blocks # noqa: B018
af.blocks
2 changes: 1 addition & 1 deletion asdf/_tests/test_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def test_tag_definition():
RuntimeError,
match=r"Cannot use .* when multiple schema URIs are present",
):
tag_def.schema_uri # noqa: B018
tag_def.schema_uri

with pytest.raises(ValueError, match=r"URI patterns are not permitted in TagDefinition"):
TagDefinition("asdf://somewhere.org/extensions/foo/tags/foo-*")
Expand Down
2 changes: 1 addition & 1 deletion asdf/_tests/test_file_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def test_invalid_source(small_tree):

# This error message changes depending on how remote-data is configured
# for the CI run.
with pytest.raises(IOError): # noqa: PT011
with pytest.raises(IOError):
ff2._blocks.get_block("http://ABadUrl.verybad/test.asdf")

with pytest.raises(TypeError, match=r"Unknown source .*"):
Expand Down
18 changes: 9 additions & 9 deletions asdf/_tests/test_generic_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def get_read_fd():

with _roundtrip(tree, get_write_fd, get_read_fd) as ff:
assert len(list(ff._blocks.internal_blocks)) == 2
next(ff._blocks.internal_blocks).data # noqa: B018
next(ff._blocks.internal_blocks).data
assert isinstance(next(ff._blocks.internal_blocks)._data, np.core.memmap)


Expand All @@ -122,15 +122,15 @@ def test_open2(tree, tmp_path):

def get_write_fd():
# cannot use context manager here because it closes the file
f = generic_io.get_file(open(path, "wb"), mode="w", close=True) # noqa: SIM115
f = generic_io.get_file(open(path, "wb"), mode="w", close=True)
assert isinstance(f, generic_io.RealFile)
assert f._uri == util.filepath_to_url(path)
return f

def get_read_fd():
# Must open with mode=rw in order to get memmapped data
# cannot use context manager here because it closes the file
f = generic_io.get_file(open(path, "r+b"), mode="rw", close=True) # noqa: SIM115
f = generic_io.get_file(open(path, "r+b"), mode="rw", close=True)
assert isinstance(f, generic_io.RealFile)
assert f._uri == util.filepath_to_url(path)
return f
Expand Down Expand Up @@ -160,14 +160,14 @@ def test_io_open(tree, tmp_path):

def get_write_fd():
# cannot use context manager here because it closes the file
f = generic_io.get_file(open(path, "wb"), mode="w", close=True) # noqa: SIM115
f = generic_io.get_file(open(path, "wb"), mode="w", close=True)
assert isinstance(f, generic_io.RealFile)
assert f._uri == util.filepath_to_url(path)
return f

def get_read_fd():
# cannot use context manager here because it closes the file
f = generic_io.get_file(open(path, "r+b"), mode="rw", close=True) # noqa: SIM115
f = generic_io.get_file(open(path, "r+b"), mode="rw", close=True)
assert isinstance(f, generic_io.RealFile)
assert f._uri == util.filepath_to_url(path)
return f
Expand Down Expand Up @@ -249,7 +249,7 @@ def test_urlopen(tree, httpserver):

def get_write_fd():
# cannot use context manager here because it closes the file
return generic_io.get_file(open(path, "wb"), mode="w") # noqa: SIM115
return generic_io.get_file(open(path, "wb"), mode="w")

def get_read_fd():
return generic_io.get_file(urllib_request.urlopen(httpserver.url + "test.asdf"))
Expand All @@ -266,7 +266,7 @@ def test_http_connection(tree, httpserver):

def get_write_fd():
# cannot use context manager here because it closes the file
return generic_io.get_file(open(path, "wb"), mode="w") # noqa: SIM115
return generic_io.get_file(open(path, "wb"), mode="w")

def get_read_fd():
fd = generic_io.get_file(httpserver.url + "test.asdf")
Expand Down Expand Up @@ -739,12 +739,12 @@ def test_blocksize(tree, tmp_path):

def get_write_fd():
# cannot use context manager here because it closes the file
return generic_io.get_file(open(path, "wb"), mode="w", close=True) # noqa: SIM115
return generic_io.get_file(open(path, "wb"), mode="w", close=True)

def get_read_fd():
# Must open with mode=rw in order to get memmapped data
# cannot use context manager here because it closes the file
return generic_io.get_file(open(path, "r+b"), mode="rw", close=True) # noqa: SIM115
return generic_io.get_file(open(path, "r+b"), mode="rw", close=True)

with config_context() as config:
config.io_block_size = 1233 # make sure everything works with a strange blocksize
Expand Down
2 changes: 1 addition & 1 deletion asdf/_tests/test_reference_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_reference_file(reference_file):

try:
_compare_trees(name_without_ext, expect_warnings=expect_warnings)
except Exception: # noqa: BLE001
except Exception:
if known_fail:
pytest.xfail()
else:
Expand Down
4 changes: 2 additions & 2 deletions asdf/_tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ def test_multiple_results(asdf_file):
assert "root['nested']['foo']" in result.paths

with pytest.raises(RuntimeError, match=r"More than one result"):
result.path # noqa: B018
result.path

with pytest.raises(RuntimeError, match=r"More than one result"):
result.node # noqa: B018
result.node

result.replace(54)
assert asdf_file["foo"] == 54
Expand Down
6 changes: 3 additions & 3 deletions asdf/_tests/test_tagged.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_tagged_list_isinstance():
def test_tagged_list_base():
value = TaggedList([0, 1, 2, ["foo"]], "tag:nowhere.org:custom/foo-1.0.0")

assert not (value == value.base) # base is not a tagged list # noqa: SIM201
assert not (value == value.base) # base is not a tagged list
assert value.data == value.base # but the data is

assert isinstance(value.base, list)
Expand Down Expand Up @@ -78,7 +78,7 @@ def test_tagged_dict_isinstance():
def test_tagged_dict_base():
value = TaggedDict({"a": 0, "b": 1, "c": 2, "nested": {"d": 3}}, "tag:nowhere.org:custom/foo-1.0.0")

assert not (value == value.base) # base is not a tagged dict # noqa: SIM201
assert not (value == value.base) # base is not a tagged dict
assert value.data == value.base # but the data is

assert isinstance(value.base, dict)
Expand Down Expand Up @@ -111,7 +111,7 @@ def test_tagged_string_base():
value = TaggedString("You're it!")
value._tag = "tag:nowhere.org:custom/foo-1.0.0"

assert not (value == value.base) # base is not a tagged dict # noqa: SIM201
assert not (value == value.base) # base is not a tagged dict
assert value.data == value.base # but the data is

assert isinstance(value.base, str)
Expand Down
4 changes: 2 additions & 2 deletions asdf/_tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def from_tree(cls, tree, ctx):


def fractional2dcoordtype_factory():
FractionType = fractiontype_factory() # noqa: N806
FractionType = fractiontype_factory()

with pytest.warns(AsdfDeprecationWarning, match=".*subclasses the deprecated CustomType.*"):

Expand Down Expand Up @@ -119,7 +119,7 @@ def types(self):


def test_custom_tag():
FractionType = fractiontype_factory() # noqa: N806
FractionType = fractiontype_factory()

class FractionExtension(CustomExtension):
@property
Expand Down
100 changes: 50 additions & 50 deletions asdf/_tests/test_versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def test_version_and_version_equality():
assert ver0 is not ver1
assert ver0 == ver1
assert ver1 == ver0
assert not (ver0 != ver1) # noqa: SIM202
assert not (ver1 != ver0) # noqa: SIM202
assert not (ver0 != ver1)
assert not (ver1 != ver0)


def test_version_and_string_equality():
Expand All @@ -50,8 +50,8 @@ def test_version_and_string_equality():

assert version == string_ver
assert string_ver == version
assert not (version != string_ver) # noqa: SIM202
assert not (string_ver != version) # noqa: SIM202
assert not (version != string_ver)
assert not (string_ver != version)


def test_version_and_tuple_equality():
Expand All @@ -60,8 +60,8 @@ def test_version_and_tuple_equality():

assert version == tuple_ver
assert tuple_ver == version
assert not (version != tuple_ver) # noqa: SIM202
assert not (tuple_ver != version) # noqa: SIM202
assert not (version != tuple_ver)
assert not (tuple_ver != version)


def test_version_and_version_inequality():
Expand All @@ -76,7 +76,7 @@ def test_version_and_version_inequality():

versions = [ver0, ver1, ver2, ver3, ver4, ver5, ver6, ver7]
for x, y in combinations(versions, 2):
assert not (x == y) # noqa: SIM201
assert not (x == y)
assert x != y

assert ver0 < ver1 < ver2 < ver3 < ver4 < ver5 < ver6 < ver7
Expand Down Expand Up @@ -111,25 +111,25 @@ def test_version_and_string_inequality():
assert version <= "2.1.0"
assert version <= "2.1.1"

assert "1.0.0" < version # noqa: SIM300
assert "1.0.1" < version # noqa: SIM300
assert "1.1.0" < version # noqa: SIM300
assert "1.1.1" < version # noqa: SIM300
assert ("2.0.0" < version) is False # noqa: SIM300
assert ("2.0.0" > version) is False # noqa: SIM300
assert "2.0.1" > version # noqa: SIM300
assert "2.1.0" > version # noqa: SIM300
assert "2.1.1" > version # noqa: SIM300

assert "1.0.0" <= version # noqa: SIM300
assert "1.0.1" <= version # noqa: SIM300
assert "1.1.0" <= version # noqa: SIM300
assert "1.1.1" <= version # noqa: SIM300
assert "2.0.0" <= version # noqa: SIM300
assert "2.0.0" >= version # noqa: SIM300
assert "2.0.1" >= version # noqa: SIM300
assert "2.1.0" >= version # noqa: SIM300
assert "2.1.1" >= version # noqa: SIM300
assert "1.0.0" < version
assert "1.0.1" < version
assert "1.1.0" < version
assert "1.1.1" < version
assert ("2.0.0" < version) is False
assert ("2.0.0" > version) is False
assert "2.0.1" > version
assert "2.1.0" > version
assert "2.1.1" > version

assert "1.0.0" <= version
assert "1.0.1" <= version
assert "1.1.0" <= version
assert "1.1.1" <= version
assert "2.0.0" <= version
assert "2.0.0" >= version
assert "2.0.1" >= version
assert "2.1.0" >= version
assert "2.1.1" >= version


def test_version_and_tuple_inequality():
Expand All @@ -155,25 +155,25 @@ def test_version_and_tuple_inequality():
assert version <= (2, 1, 0)
assert version <= (2, 1, 1)

assert (1, 0, 0) < version # noqa: SIM300
assert (1, 0, 1) < version # noqa: SIM300
assert (1, 1, 0) < version # noqa: SIM300
assert (1, 1, 1) < version # noqa: SIM300
assert ((2, 0, 0) < version) is False # noqa: SIM300
assert ((2, 0, 0) > version) is False # noqa: SIM300
assert (2, 0, 1) > version # noqa: SIM300
assert (2, 1, 0) > version # noqa: SIM300
assert (2, 1, 1) > version # noqa: SIM300

assert (1, 0, 0) <= version # noqa: SIM300
assert (1, 0, 1) <= version # noqa: SIM300
assert (1, 1, 0) <= version # noqa: SIM300
assert (1, 1, 1) <= version # noqa: SIM300
assert (2, 0, 0) <= version # noqa: SIM300
assert (2, 0, 0) >= version # noqa: SIM300
assert (2, 0, 1) >= version # noqa: SIM300
assert (2, 1, 0) >= version # noqa: SIM300
assert (2, 1, 1) >= version # noqa: SIM300
assert (1, 0, 0) < version
assert (1, 0, 1) < version
assert (1, 1, 0) < version
assert (1, 1, 1) < version
assert ((2, 0, 0) < version) is False
assert ((2, 0, 0) > version) is False
assert (2, 0, 1) > version
assert (2, 1, 0) > version
assert (2, 1, 1) > version

assert (1, 0, 0) <= version
assert (1, 0, 1) <= version
assert (1, 1, 0) <= version
assert (1, 1, 1) <= version
assert (2, 0, 0) <= version
assert (2, 0, 0) >= version
assert (2, 0, 1) >= version
assert (2, 1, 0) >= version
assert (2, 1, 1) >= version


def test_spec_version_match():
Expand Down Expand Up @@ -266,14 +266,14 @@ def test_spec_equal():
assert version1 == spec

assert spec != "1.1.0"
assert "1.1.0" != spec # noqa: SIM300
assert "1.1.0" != spec
assert spec == "1.3.0"
assert "1.3.0" == spec # noqa: SIM300
assert "1.3.0" == spec

assert spec != (1, 1, 0)
assert (1, 1, 0) != spec # noqa: SIM300
assert (1, 1, 0) != spec
assert spec == (1, 3, 0)
assert (1, 3, 0) == spec # noqa: SIM300
assert (1, 3, 0) == spec


def _standard_versioned_tags():
Expand Down Expand Up @@ -358,7 +358,7 @@ def _warn_tag_mismatch(self, *args, **kwargs):

try:
load_schema(tag)
except Exception as err: # noqa: BLE001
except Exception as err:
msg = (
f"ASDF Standard version {version} requires support for "
f"{tag}, but the corresponding schema cannot be loaded."
Expand Down
Loading

0 comments on commit 9bcdbbe

Please sign in to comment.