Skip to content

Commit

Permalink
Use FutureWarning instead of DeprecationWarning. (#692)
Browse files Browse the repository at this point in the history
* Update __init__.py

* Update indexing.py

* Update collection_json.py

* Update file_buffered_collection.py

* Update __init__.py

* Update file_buffered_collection.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update test_json_collection.py

* Update conftest.py

* Removed deprecated_in_version function and use pytest.deprecated_call() instead.. It was only used once and is no longer needed.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Remove unused imports.

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bradley Dice <[email protected]>
  • Loading branch information
3 people authored Mar 12, 2022
1 parent 050de42 commit 045925c
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 23 deletions.
2 changes: 1 addition & 1 deletion signac/contrib/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ def __init__(self, *args, **kwargs):
warnings.warn(
"The MasterCrawler class has been replaced by the MainCrawler class. "
"Both classes are deprecated and will be removed in a future release.",
DeprecationWarning,
FutureWarning,
)
super().__init__(*args, **kwargs)

Expand Down
4 changes: 2 additions & 2 deletions signac/synced_collections/backends/collection_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _str_key(key):
warnings.warn(
f"Use of {type(key).__name__} as key is deprecated "
"and will be removed in version 2.0",
DeprecationWarning,
FutureWarning,
)
key = str(key)
return key
Expand Down Expand Up @@ -146,7 +146,7 @@ def json_attr_dict_validator(data):
warnings.warn(
f"Use of {type(key).__name__} as key is deprecated "
"and will be removed in version 2.0.",
DeprecationWarning,
FutureWarning,
)
data[str(key)] = data.pop(key)
else:
Expand Down
8 changes: 4 additions & 4 deletions signac/synced_collections/buffers/file_buffered_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,9 @@ def buffer_backend(cls, buffer_size=None, force_write=None, *args, **kwargs):
"""
if force_write is not None:
warnings.warn(
DeprecationWarning(
"The force_write parameter is deprecated and will be removed in "
"signac 2.0. This functionality is no longer supported."
)
"The force_write parameter is deprecated and will be removed in "
"signac 2.0. This functionality is no longer supported.",
FutureWarning,
)

return cls._buffer_context(buffer_size)
13 changes: 0 additions & 13 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
import uuid
from contextlib import contextmanager

import pytest
from packaging import version

import signac


@contextmanager
def deprecated_in_version(version_string):
if version.parse(version_string) <= version.parse(signac.__version__):
with pytest.deprecated_call():
yield
else:
yield


@pytest.fixture
Expand Down
3 changes: 1 addition & 2 deletions tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import pytest
import test_h5store
from conftest import deprecated_in_version
from packaging import version
from test_job import TestJobBase

Expand Down Expand Up @@ -1099,7 +1098,7 @@ def test_temp_project(self):
assert not os.path.isdir(tmp_root_dir)

def test_access_module(self):
with deprecated_in_version("1.5"):
with pytest.deprecated_call():
self.project.create_access_module()


Expand Down
2 changes: 1 addition & 1 deletion tests/test_synced_collections/test_json_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class TestJSONDict(JSONCollectionTest, SyncedDictTest):
# See issue: https://github.com/glotzerlab/signac/issues/316.
def test_keys_non_str_valid_type(self, synced_collection, testdata):
for key in (0, None, True):
with pytest.deprecated_call(match="Use of.+as key is deprecated"):
with pytest.warns(FutureWarning, match="Use of.+as key is deprecated"):
synced_collection[key] = testdata
assert str(key) in synced_collection
assert synced_collection[str(key)] == testdata
Expand Down

0 comments on commit 045925c

Please sign in to comment.