Skip to content

Commit 546b191

Browse files
committed
Linting.
1 parent 7b14b28 commit 546b191

File tree

7 files changed

+71
-65
lines changed

7 files changed

+71
-65
lines changed

__pkginfo__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
repo_root = pathlib.Path(__file__).parent
3232
install_requires = (repo_root / "requirements.txt").read_text(encoding="utf-8").split('\n')
3333
extras_require = {
34-
'dates': ['pytz>=2019.1'],
35-
'testing': ['pytest>=6.0.0', 'pytest-regressions>=2.0.2'],
36-
'all': ['pytest-regressions>=2.0.2', 'pytest>=6.0.0', 'pytz>=2019.1']
34+
"dates": ["pytz>=2019.1"],
35+
"testing": ["pytest>=6.0.0", "pytest-regressions>=2.0.2"],
36+
"all": ["pytest-regressions>=2.0.2", "pytest>=6.0.0", "pytz>=2019.1"]
3737
}

doc-source/Source.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Downloading source code
33
=========================
44

55
The ``domdf_python_tools`` source code is available on GitHub,
6-
and can be accessed from the following URL: https://github.com/domdfcoding/domdf_python_tools"
6+
and can be accessed from the following URL: https://github.com/domdfcoding/domdf_python_tools
77

88
If you have ``git`` installed, you can clone the repository with the following command:
99

doc-source/conf.py

Lines changed: 43 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import sys
99

1010
sys.path.append(os.path.abspath('.'))
11-
sys.path.append(os.path.abspath('..'))
11+
sys.path.append(os.path.abspath(".."))
1212

1313
# 3rd party
1414
import domdf_python_tools
@@ -32,69 +32,66 @@
3232
slug = re.sub(r'\W+', '-', project.lower())
3333
release = version = __version__
3434
copyright = "2019-2020 Dominic Davis-Foster" # pylint: disable=redefined-builtin
35-
language = 'en'
35+
language = "en"
3636
package_root = "domdf_python_tools"
3737

3838
extensions = [
39-
'sphinx_toolbox',
40-
'sphinx_toolbox.more_autodoc',
41-
'sphinx_toolbox.more_autosummary',
42-
'sphinx_toolbox.tweaks.param_dash',
43-
'sphinx.ext.intersphinx',
44-
'sphinx.ext.mathjax',
45-
'sphinxcontrib.httpdomain',
46-
'sphinxcontrib.extras_require',
47-
'sphinx.ext.todo',
48-
'sphinxemoji.sphinxemoji',
49-
'notfound.extension',
50-
'sphinx_copybutton',
51-
'sphinxcontrib.default_values',
52-
'sphinxcontrib.toctree_plus',
53-
'seed_intersphinx_mapping',
54-
'sphinx_autofixture',
39+
"sphinx_toolbox",
40+
"sphinx_toolbox.more_autodoc",
41+
"sphinx_toolbox.more_autosummary",
42+
"sphinx_toolbox.tweaks.param_dash",
43+
"sphinx.ext.intersphinx",
44+
"sphinx.ext.mathjax",
45+
"sphinxcontrib.httpdomain",
46+
"sphinxcontrib.extras_require",
47+
"sphinx.ext.todo",
48+
"sphinxemoji.sphinxemoji",
49+
"notfound.extension",
50+
"sphinx_copybutton",
51+
"sphinxcontrib.default_values",
52+
"sphinxcontrib.toctree_plus",
53+
"seed_intersphinx_mapping",
54+
"sphinx_autofixture",
5555
]
5656

57-
sphinxemoji_style = 'twemoji'
57+
sphinxemoji_style = "twemoji"
5858
todo_include_todos = bool(os.environ.get("SHOW_TODOS", 0))
5959
gitstamp_fmt = "%d %b %Y"
6060

61-
templates_path = ['_templates']
62-
html_static_path = ['_static']
63-
source_suffix = '.rst'
61+
templates_path = ["_templates"]
62+
html_static_path = ["_static"]
63+
source_suffix = ".rst"
6464
exclude_patterns = []
6565

66-
master_doc = 'index'
67-
suppress_warnings = ['image.nonlocal_uri']
68-
pygments_style = 'default'
66+
master_doc = "index"
67+
suppress_warnings = ["image.nonlocal_uri"]
68+
pygments_style = "default"
6969

7070
intersphinx_mapping = {
71-
'python': ('https://docs.python.org/3/', None),
72-
'sphinx': ('https://www.sphinx-doc.org/en/stable/', None),
73-
'pandas': ('https://pandas.pydata.org/docs/', None),
74-
'consolekit': ('https://consolekit.readthedocs.io/en/latest/', None),
75-
'pytest': ('https://docs.pytest.org/en/stable', None),
71+
"python": ("https://docs.python.org/3/", None),
72+
"sphinx": ("https://www.sphinx-doc.org/en/stable/", None),
73+
"pandas": ("https://pandas.pydata.org/docs/", None),
74+
"consolekit": ("https://consolekit.readthedocs.io/en/latest/", None),
75+
"pytest": ("https://docs.pytest.org/en/stable", None),
7676
}
7777

78-
html_theme = 'domdf_sphinx_theme'
79-
html_theme_options = {
80-
'logo_only': False,
81-
}
78+
html_theme = "domdf_sphinx_theme"
79+
html_theme_options = {"logo_only": False}
8280
html_theme_path = ["../.."]
8381
html_show_sourcelink = True # True will show link to source
8482

8583
html_context = {
86-
'display_github': True,
87-
'github_user': 'domdfcoding',
88-
'github_repo': 'domdf_python_tools',
89-
'github_version': 'master',
90-
'conf_py_path': '/doc-source/',
84+
"display_github": True,
85+
"github_user": "domdfcoding",
86+
"github_repo": "domdf_python_tools",
87+
"github_version": "master",
88+
"conf_py_path": "/doc-source/",
9189
}
92-
9390
htmlhelp_basename = slug
9491

95-
latex_documents = [('index', f'{slug}.tex', project, author, 'manual')]
96-
man_pages = [('index', slug, project, [author], 1)]
97-
texinfo_documents = [('index', slug, project, author, slug, project, 'Miscellaneous')]
92+
latex_documents = [("index", f'{slug}.tex', project, author, "manual")]
93+
man_pages = [("index", slug, project, [author], 1)]
94+
texinfo_documents = [("index", slug, project, author, slug, project, "Miscellaneous")]
9895

9996
toctree_plus_types = {
10097
"class",
@@ -138,11 +135,11 @@
138135
"__hash__",
139136
]
140137
autodoc_default_options = {
141-
'members': None, # Include all members (methods).
142-
'special-members': None,
138+
"members": None, # Include all members (methods).
139+
"special-members": None,
143140
"autosummary": None,
144141
"show-inheritance": None,
145-
'exclude-members': ','.join(autodoc_exclude_members),
142+
"exclude-members": ','.join(autodoc_exclude_members),
146143
}
147144

148145
manpages_url = "https://manpages.debian.org/{path}"

domdf_python_tools/dates.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,19 +296,25 @@ def get_timezone(tz: str, date: Optional[datetime.datetime] = None) -> Optional[
296296

297297
if __name__ == "__main__":
298298

299+
# stdlib
299300
import warnings
301+
302+
# this package
300303
from domdf_python_tools.words import word_join
301304

302-
warnings.warn(f"""\
305+
warnings.warn(
306+
f"""\
303307
'{word_join(_pytz_functions)}' require pytz (https://pypi.org/project/pytz/), but it could not be imported.
304308
305309
The error was: {e}.
306-
""")
310+
"""
311+
)
307312

308313
else:
309314
_actual_module = sys.modules[__name__]
310315

311316
class SelfWrapper(ModuleType):
317+
312318
def __getattr__(self, name):
313319
if name in _pytz_functions:
314320
raise ImportError(

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from __pkginfo__ import * # pylint: disable=wildcard-import
1414

1515
setup(
16-
description='Helpful functions for Python\u2002🐍\u2002🛠️',
16+
description="Helpful functions for Python 🐍 🛠️",
1717
extras_require=extras_require,
1818
install_requires=install_requires,
1919
py_modules=[],

tests/test_dates.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@
1818
from domdf_python_tools.dates import calc_easter
1919
from domdf_python_tools.testing import count
2020

21-
2221
# TODO: travis matrix to test without pytz installed
2322
# TODO: test get_timezone
2423

25-
2624
try:
25+
# 3rd party
2726
import pytz
2827

2928
test_date = datetime.datetime(1996, 10, 13, 2, 20).replace(tzinfo=pytz.utc)
@@ -58,7 +57,6 @@ def test_utc_offset():
5857
}
5958
assert dates.get_utc_offset("Africa/Algiers") == datetime.timedelta(0, 3600)
6059

61-
6260
def test_converting_timezone():
6361
# No matter what timezone we convert to the timestamp should be the same
6462
for tz in pytz.all_timezones:
@@ -73,7 +71,6 @@ def test_converting_timezone():
7371
if dates.get_utc_offset(tz, today): # otherwise the timezone stayed as UTC
7472
assert today.astimezone(dates.get_timezone(tz, today)).hour != today.hour
7573

76-
7774
def test_utc_timestamp_to_datetime():
7875
# Going from a datetime object to timezone and back should give us the same object
7976
for tz in pytz.all_timezones:
@@ -86,7 +83,6 @@ def test_utc_timestamp_to_datetime():
8683
dt = today.astimezone(tzinfo)
8784
assert dates.utc_timestamp_to_datetime(dt.timestamp(), tzinfo) == dt
8885

89-
9086
def test_set_timezone():
9187
# Setting the timezone should change the timestamp
9288
for tz in pytz.all_timezones:
@@ -142,20 +138,25 @@ def test_set_timezone():
142138
as_seconds = dates.set_timezone(test_date, target_tz).timestamp() + offset.total_seconds()
143139
assert as_seconds == test_date.timestamp()
144140

145-
146141
except ImportError:
147142

148143
def test_utc_offset_no_pytz():
149-
with pytest.raises(ImportError, match="'get_utc_offset' requires pytz \(.*\), but it could not be imported"):
144+
with pytest.raises(
145+
ImportError,
146+
match=r"'get_utc_offset' requires pytz \(.*\), but it could not be imported",
147+
):
150148
dates.get_utc_offset
151149

152-
with pytest.raises(ImportError, match="'get_utc_offset' requires pytz \(.*\), but it could not be imported"):
150+
with pytest.raises(
151+
ImportError,
152+
match=r"'get_utc_offset' requires pytz \(.*\), but it could not be imported",
153+
):
154+
# this package
153155
from domdf_python_tools.dates import get_utc_offset
154156

155157

156158
# TODO: Finish
157159

158-
159160
months = [
160161
"January",
161162
"February",

tox.ini

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,17 @@ python =
3838

3939
[gh-actions]
4040
python =
41-
3.6: py36, build
41+
3.6: py36, build, mypy
4242
3.7: py37, build
4343
3.8: py38, build
4444
pypy3: pypy3, build
4545
3.9: py39, build
4646
3.10-dev: py310-dev, build
4747

4848
[testenv:docs]
49-
setenv = SHOW_TODOS = 1
49+
setenv =
50+
SHOW_TODOS = 1
51+
PIP_USE_FEATURE = 2020-resolver
5052
basepython = python3.8
5153
changedir = {toxinidir}/doc-source
5254
extras = all
@@ -129,7 +131,7 @@ commands =
129131
[flake8]
130132
max-line-length = 120
131133
select = E301 E303 E304 E305 E306 E502 W291 W293 W391 E226 E225 E241 E231 W292 E265 E111 E112 E113 E121 E122 E125 E127 E128 E129 E131 E133 E201 E202 E203 E211 E222 E223 E224 E225 E227 E228 E242 E251 E261 E262 E271 E272 E402 E703 E711 E712 E713 E714 E721 W504 E302 YTT101 YTT102 YTT103 YTT201 YTT202 YTT203 YTT204 YTT301 YTT302 YTT303 STRFTIME001 STRFTIME002 SXL001 PT001 PT002 PT003 PT005 PT006 PT007 PT008 PT009 PT010 PT011 PT012 PT013 PT014 PT015 PT016 PT017 PT018 PT019 PT020 PT021 RST201 RST202 RST203 RST204 RST205 RST206 RST207 RST208 RST210 RST211 RST212 RST213 RST214 RST215 RST216 RST217 RST218 RST219 RST299 RST301 RST302 RST303 RST304 RST305 RST306 RST399 RST401 RST499 RST900 RST901 RST902 RST903 Q001 Q002 Q003 A001 A002 A003 TYP001 TYP002 TYP003 TYP004 TYP005 TYP006 Y001,Y002 Y003 Y004 Y005 Y006 Y007 Y008 Y009 Y010 Y011 Y012 Y013 Y014 Y015 Y090 Y091 D100 D101 D102 D103 D104 D106 D201 D204 D207 D208 D209 D210 D211 D212 D213 D214 D215 D300 D301 D400 D402 D403 D404 D415 D417 DALL000
132-
exclude = .git,__pycache__,doc-source,old,build,dist,make_conda_recipe.py,__pkginfo__.py,setup.py
134+
exclude = .git,__pycache__,doc-source,old,build,dist,make_conda_recipe.py,__pkginfo__.py,setup.py,.tox,venv
133135
rst-directives =
134136
TODO
135137
envvar

0 commit comments

Comments
 (0)