Skip to content
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

Remove deprecationWarnings on import pyalex and remove Venues #45

Merged
merged 2 commits into from
Aug 19, 2024
Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Works()["W2741809807"]["open_access"]
{'is_oa': True, 'oa_status': 'gold', 'oa_url': 'https://doi.org/10.7717/peerj.4375'}
```

The previous works also for Authors, Venues, Institutions, Concepts and Topics
The previous works also for Authors, Sources, Institutions, Concepts and Topics

```python
Authors()["A2887243803"]
Expand Down
4 changes: 0 additions & 4 deletions pyalex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
from pyalex.api import Subfields
from pyalex.api import Topic
from pyalex.api import Topics
from pyalex.api import Venue
from pyalex.api import Venues
from pyalex.api import Work
from pyalex.api import Works
from pyalex.api import autocomplete
Expand All @@ -46,8 +44,6 @@
"Funders",
"Publishers",
"Publisher",
"Venues",
"Venue",
"Institutions",
"Institution",
"Concepts",
Expand Down
49 changes: 15 additions & 34 deletions pyalex/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,46 +483,27 @@ def __getitem__(self, key):
)


def Venue(*args, **kwargs): # deprecated
# warn about deprecation
warnings.warn(
"Venue is deprecated. Use Sources instead.",
DeprecationWarning,
stacklevel=2,
)

return Source(*args, **kwargs)


def Venues(*args, **kwargs): # deprecated
# warn about deprecation
warnings.warn(
"Venues is deprecated. Use Sources instead.",
DeprecationWarning,
stacklevel=2,
)

return Sources(*args, **kwargs)


class Concept(OpenAlexEntity):
# warn about deprecation
warnings.warn(
"Concept is deprecated by OpenAlex and replaced by topics.",
DeprecationWarning,
stacklevel=2,
)
def __init__(self, *args, **kwargs):
warnings.warn(
"Concept is deprecated by OpenAlex and replaced by topics.",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)


class Concepts(BaseOpenAlex):
# warn about deprecation
warnings.warn(
"Concepts is deprecated by OpenAlex and replaced by topics.",
DeprecationWarning,
stacklevel=2,
)
resource_class = Concept

def __init__(self, *args, **kwargs):
warnings.warn(
"Concepts is deprecated by OpenAlex and replaced by topics.",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)


def autocomplete(s):
"""autocomplete with any type of entity"""
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ force-single-line = true

[tool.pytest.ini_options]
pythonpath = ["."]
addopts = "-v"
addopts = "-v -W error"
8 changes: 6 additions & 2 deletions tests/test_pyalex.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ def test_config():
def test_meta_entities():
_, m = Authors().get(return_meta=True)
assert "count" in m
_, m = Concepts().get(return_meta=True)
assert "count" in m
_, m = Institutions().get(return_meta=True)
assert "count" in m
_, m = Sources().get(return_meta=True)
Expand All @@ -57,6 +55,12 @@ def test_meta_entities():
assert "count" in m


@pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning")
def test_meta_entities_deprecated():
_, m = Concepts().get(return_meta=True)
assert "count" in m


def test_works_params():
assert len(Works(params={"filter": {"publication_year": "2020"}}).get()) == 25

Expand Down
Loading