Skip to content

Commit

Permalink
Drop Python 3.7 or earlier support
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlia authored Jan 27, 2023
1 parent 76a29e8 commit afc9b54
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 25 deletions.
4 changes: 4 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ Version 0.8.0

To be released.

- Python 3.4---3.7 are no more supported. The minimum supported Python version
is Python 3.8. Instead, now it's tested with Python 3.8---3.11.
- :class:`~wikidata.entity.Entity` and :class:`~wikidata.client.Client` became
possible to be serialized using :mod:`pickle`. [:issue:`31`]
- Fixed a typing bug that :attr:`Entity.label <wikidata.entity.Entity.label>`
and :attr:`Entity.description <wikidata.entity.Entity.description>` properties
were incorrectly typed.
- :class:`wikidata.multilingual.MultilingualText`'s constructor became to take
only :class:`Locale` for parameter ``locale``.


Version 0.7.0
Expand Down
8 changes: 4 additions & 4 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[mypy]
python_version = 3.5
python_version = 3.8
check_untyped_defs = true
follow_imports = silent
show_none_errors = true
strict_optional = true
warn_unused_ignores = true
scripts_are_modules = true

[mypy-tests.*]
check_untyped_defs = false
warn_unused_ignores = false

[mypy-pytest.*]
ignore_missing_imports = true
[mypy-pytest.*]
12 changes: 5 additions & 7 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,13 @@ wikidata =

[options.extras_require]
tests =
flake8 >= 3.8.3
flake8 >= 6.0.0
flake8-import-order-spoqa
pytest ~= 4.6.11
pytest-flake8 ~= 1.0.6
mypy =
mypy >= 0.782
pytest ~= 7.2.1
mypy >= 0.991

[tool:pytest]
addopts = --ff --doctest-glob=*.rst --doctest-modules --flake8
addopts = --ff --doctest-glob=*.rst --doctest-modules
testpaths =
tests
wikidata
Expand All @@ -70,6 +68,6 @@ doctest_optionflags =
ELLIPSIS

[flake8]
exclude = .tox,docs,typeshed
exclude = .tox,build,dist,docs,typeshed
import-order-style = spoqa
application-import-names = wikidata, tests
4 changes: 2 additions & 2 deletions tests/datavalue_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from wikidata.datavalue import DatavalueError, Decoder
from wikidata.entity import Entity, EntityId
from wikidata.globecoordinate import GlobeCoordinate
from wikidata.multilingual import MonolingualText
from wikidata.multilingual import Locale, MonolingualText
from wikidata.quantity import Quantity


Expand Down Expand Up @@ -145,7 +145,7 @@ def test_decoder_monolingualtext(fx_client: Client):
'language': 'ko',
'text': '윤동주',
},
}) == MonolingualText('윤동주', 'ko')
}) == MonolingualText('윤동주', Locale('ko'))


def test_decoder_commonsMedia__string(fx_client: Client):
Expand Down
17 changes: 10 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
[tox]
envlist =
# CHECK If you're going to change the list of supported Python versions
# update .travis.yml and setup.py's classifiers as well.
py34, py35, py36, py37, py38, pypy3, mypy
# update .travis.yml, .devcontainer/devcontainer.json, and setup.cfg's
# classifiers as well.
py38, py39, py310, py311, pypy3, mypy, flake8

[testenv]
extras = tests
pip_version = pip
commands =
pytest {posargs:}

[testenv:py34]
pip_version = pip < 19.2

[testenv:mypy]
extras = mypy
extras = tests
basepython = python3
commands =
mypy -p wikidata
mypy -p tests

[testenv:flake8]
extras = tests
basepython = python3
commands =
flake8

[testenv:docs]
basepython = python3
deps =
Expand Down
2 changes: 1 addition & 1 deletion wikidata/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class Entity(collections.abc.Mapping, collections.abc.Hashable):
def __init__(self, id: EntityId, client: 'Client') -> None:
self.id = id
self.client = client
self.data = None # type: Optional[Mapping[str, object]]
self.data: Optional[Mapping[str, object]] = None
self.state = EntityState.not_loaded # type: EntityState

def __eq__(self, other) -> bool:
Expand Down
18 changes: 14 additions & 4 deletions wikidata/multilingual.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
import collections.abc
from typing import Iterator, Mapping, NewType, Type, Union
from typing import Iterator, Mapping, NewType, Type, Union, cast

__all__ = 'Locale', 'MonolingualText', 'MultilingualText'

Expand Down Expand Up @@ -59,15 +59,25 @@ class MonolingualText(str):
Locale-denoted text. It's almost equivalent to :class:`str` (and indeed
subclasses :class:`str`) except that it has an extra attribute,
:attr:`locale`, that denotes what language the text is written in.
.. versionchanged:: 0.8.0
The type hint of the constructor's ``locale`` parameter became
:class:`Locale`.
"""

#: (:class:`Locale`) The code of :attr:`locale`.
locale = None # type: Locale
#:
#: .. versionchanged:: 0.7.0
#:
#: The type became :class:`Locale` (was :class:`babel.core.Locale`).
locale: Locale

def __new__(cls: Type[str],
text: str,
locale: Union[Locale, str]) -> 'MonolingualText':
self = str.__new__(cls, text) # type: ignore
locale: Locale) -> 'MonolingualText':
self = cast(MonolingualText, str.__new__(cls, text))
self.locale = locale
return self

Expand Down

0 comments on commit afc9b54

Please sign in to comment.