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

Use tomllib/tomli over toml #284

Merged
merged 2 commits into from
May 1, 2023
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
4 changes: 2 additions & 2 deletions pyperformance/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ def _is_devel_install():
# This means it creates a link back to the checkout instead
# of copying the files.
try:
import toml
import packaging
except ModuleNotFoundError:
return False
sitepackages = os.path.dirname(os.path.dirname(toml.__file__))
sitepackages = os.path.dirname(os.path.dirname(packaging.__file__))
if os.path.isdir(os.path.join(sitepackages, 'pyperformance')):
return False
if not os.path.exists(os.path.join(sitepackages, 'pyperformance.egg-link')):
Expand Down
8 changes: 6 additions & 2 deletions pyperformance/_pyproject_toml.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
import packaging.specifiers
import packaging.utils
import packaging.version
import toml

try:
import tomllib
except ImportError:
import tomli as tomllib

from ._utils import check_name

Expand Down Expand Up @@ -52,7 +56,7 @@ def parse_pyproject_toml(text, rootdir, name=None, *,
tools=None,
requirefiles=True,
):
data = toml.loads(text)
data = tomllib.loads(text)
unused = list(data)

for section, normalize in SECTIONS.items():
Expand Down
10 changes: 3 additions & 7 deletions pyperformance/data-files/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --output-file=requirements.txt requirements.in
# pip-compile --output-file=pyperformance/data-files/requirements.txt requirements.in
#
packaging==21.3
packaging==23.1
# via -r requirements.in
psutil==5.9.0
psutil==5.9.5
# via
# -r requirements.in
# pyperf
pyparsing==3.0.8
# via packaging
pyperf==2.6.0
# via -r requirements.in
toml==0.10.2
# via -r requirements.in
Comment on lines -7 to -18
Copy link
Member Author

@AlexWaygood AlexWaygood Apr 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran pip-compile to regenerate this file, and it also bumped packaging and psutil. Not sure if that's desirable or if I did something wrong there! Not had much experience using pip-compile.

6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ classifiers = [
'Programming Language :: Python',
]
requires-python = ">=3.7"
dependencies = ["pyperf", "toml", "packaging"]
dependencies = [
"pyperf",
"tomli; python_version < '3.11'",
"packaging",
]

[project.optional-dependencies]
dev = [
Expand Down
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pyperf

# for benchmark metadata:
packaging
toml
tomli; python_version < '3.11'


# Optional dependencies
Expand Down
Loading