Skip to content

Commit c899b36

Browse files
authored
Remove deprecationWarnings on import pyalex and remove Venues (#45)
1 parent a1d1930 commit c899b36

File tree

5 files changed

+23
-42
lines changed

5 files changed

+23
-42
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Works()["W2741809807"]["open_access"]
9999
{'is_oa': True, 'oa_status': 'gold', 'oa_url': 'https://doi.org/10.7717/peerj.4375'}
100100
```
101101

102-
The previous works also for Authors, Venues, Institutions, Concepts and Topics
102+
The previous works also for Authors, Sources, Institutions, Concepts and Topics
103103

104104
```python
105105
Authors()["A2887243803"]

pyalex/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
from pyalex.api import Subfields
2828
from pyalex.api import Topic
2929
from pyalex.api import Topics
30-
from pyalex.api import Venue
31-
from pyalex.api import Venues
3230
from pyalex.api import Work
3331
from pyalex.api import Works
3432
from pyalex.api import autocomplete
@@ -46,8 +44,6 @@
4644
"Funders",
4745
"Publishers",
4846
"Publisher",
49-
"Venues",
50-
"Venue",
5147
"Institutions",
5248
"Institution",
5349
"Concepts",

pyalex/api.py

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -483,46 +483,27 @@ def __getitem__(self, key):
483483
)
484484

485485

486-
def Venue(*args, **kwargs): # deprecated
487-
# warn about deprecation
488-
warnings.warn(
489-
"Venue is deprecated. Use Sources instead.",
490-
DeprecationWarning,
491-
stacklevel=2,
492-
)
493-
494-
return Source(*args, **kwargs)
495-
496-
497-
def Venues(*args, **kwargs): # deprecated
498-
# warn about deprecation
499-
warnings.warn(
500-
"Venues is deprecated. Use Sources instead.",
501-
DeprecationWarning,
502-
stacklevel=2,
503-
)
504-
505-
return Sources(*args, **kwargs)
506-
507-
508486
class Concept(OpenAlexEntity):
509-
# warn about deprecation
510-
warnings.warn(
511-
"Concept is deprecated by OpenAlex and replaced by topics.",
512-
DeprecationWarning,
513-
stacklevel=2,
514-
)
487+
def __init__(self, *args, **kwargs):
488+
warnings.warn(
489+
"Concept is deprecated by OpenAlex and replaced by topics.",
490+
DeprecationWarning,
491+
stacklevel=2,
492+
)
493+
super().__init__(*args, **kwargs)
515494

516495

517496
class Concepts(BaseOpenAlex):
518-
# warn about deprecation
519-
warnings.warn(
520-
"Concepts is deprecated by OpenAlex and replaced by topics.",
521-
DeprecationWarning,
522-
stacklevel=2,
523-
)
524497
resource_class = Concept
525498

499+
def __init__(self, *args, **kwargs):
500+
warnings.warn(
501+
"Concepts is deprecated by OpenAlex and replaced by topics.",
502+
DeprecationWarning,
503+
stacklevel=2,
504+
)
505+
super().__init__(*args, **kwargs)
506+
526507

527508
def autocomplete(s):
528509
"""autocomplete with any type of entity"""

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ force-single-line = true
4141

4242
[tool.pytest.ini_options]
4343
pythonpath = ["."]
44-
addopts = "-v"
44+
addopts = "-v -W error"

tests/test_pyalex.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ def test_config():
3737
def test_meta_entities():
3838
_, m = Authors().get(return_meta=True)
3939
assert "count" in m
40-
_, m = Concepts().get(return_meta=True)
41-
assert "count" in m
4240
_, m = Institutions().get(return_meta=True)
4341
assert "count" in m
4442
_, m = Sources().get(return_meta=True)
@@ -57,6 +55,12 @@ def test_meta_entities():
5755
assert "count" in m
5856

5957

58+
@pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning")
59+
def test_meta_entities_deprecated():
60+
_, m = Concepts().get(return_meta=True)
61+
assert "count" in m
62+
63+
6064
def test_works_params():
6165
assert len(Works(params={"filter": {"publication_year": "2020"}}).get()) == 25
6266

0 commit comments

Comments
 (0)