Skip to content

Commit b9c1811

Browse files
authored
Merge pull request #108 from mseitzer/black
Add code formatting with black
2 parents 46e6974 + af953a9 commit b9c1811

File tree

9 files changed

+226
-189
lines changed

9 files changed

+226
-189
lines changed

.flake8

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[flake8]
2+
select = F,W,E,I,B,B9
3+
ignore = W503,E203,B950
4+
max-line-length = 88

noxfile.py

+15-12
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
import nox
22

3-
LOCATIONS = ('src/', 'tests/', 'noxfile.py', 'setup.py')
3+
LOCATIONS = ("src/", "tests/", "noxfile.py", "setup.py")
44

55

66
@nox.session
77
def lint(session):
8-
session.install('flake8')
9-
session.install('flake8-bugbear')
10-
session.install('flake8-isort')
8+
session.install("flake8")
9+
session.install("flake8-bugbear")
10+
session.install("flake8-isort")
11+
session.install("black==24.3.0")
1112

1213
args = session.posargs or LOCATIONS
13-
session.run('flake8', *args)
14+
session.run("flake8", *args)
15+
session.run("black", "--check", "--diff", *args)
1416

1517

1618
@nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12"])
1719
def tests(session):
1820
session.install(
19-
'torch==2.2.1',
20-
'torchvision',
21-
'--index-url', 'https://download.pytorch.org/whl/cpu'
21+
"torch==2.2.1",
22+
"torchvision",
23+
"--index-url",
24+
"https://download.pytorch.org/whl/cpu",
2225
)
23-
session.install('.')
24-
session.install('pytest')
25-
session.install('pytest-mock')
26-
session.run('pytest', *session.posargs)
26+
session.install(".")
27+
session.install("pytest")
28+
session.install("pytest-mock")
29+
session.run("pytest", *session.posargs)

pyproject.toml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[tool.black]
2+
target-version = ["py311"]
3+
4+
[tool.isort]
5+
profile = "black"
6+
line_length = 88
7+
multi_line_output = 3

setup.cfg

-8
This file was deleted.

setup.py

+28-28
Original file line numberDiff line numberDiff line change
@@ -5,51 +5,51 @@
55

66
def read(rel_path):
77
base_path = os.path.abspath(os.path.dirname(__file__))
8-
with open(os.path.join(base_path, rel_path), 'r') as f:
8+
with open(os.path.join(base_path, rel_path), "r") as f:
99
return f.read()
1010

1111

1212
def get_version(rel_path):
1313
for line in read(rel_path).splitlines():
14-
if line.startswith('__version__'):
14+
if line.startswith("__version__"):
1515
# __version__ = "0.9"
1616
delim = '"' if '"' in line else "'"
1717
return line.split(delim)[1]
1818

19-
raise RuntimeError('Unable to find version string.')
19+
raise RuntimeError("Unable to find version string.")
2020

2121

22-
if __name__ == '__main__':
22+
if __name__ == "__main__":
2323
setuptools.setup(
24-
name='pytorch-fid',
25-
version=get_version(os.path.join('src', 'pytorch_fid', '__init__.py')),
26-
author='Max Seitzer',
27-
description=('Package for calculating Frechet Inception Distance (FID)'
28-
' using PyTorch'),
29-
long_description=read('README.md'),
30-
long_description_content_type='text/markdown',
31-
url='https://github.com/mseitzer/pytorch-fid',
32-
package_dir={'': 'src'},
33-
packages=setuptools.find_packages(where='src'),
24+
name="pytorch-fid",
25+
version=get_version(os.path.join("src", "pytorch_fid", "__init__.py")),
26+
author="Max Seitzer",
27+
description=(
28+
"Package for calculating Frechet Inception Distance (FID)" " using PyTorch"
29+
),
30+
long_description=read("README.md"),
31+
long_description_content_type="text/markdown",
32+
url="https://github.com/mseitzer/pytorch-fid",
33+
package_dir={"": "src"},
34+
packages=setuptools.find_packages(where="src"),
3435
classifiers=[
35-
'Programming Language :: Python :: 3',
36-
'License :: OSI Approved :: Apache Software License',
36+
"Programming Language :: Python :: 3",
37+
"License :: OSI Approved :: Apache Software License",
3738
],
38-
python_requires='>=3.5',
39+
python_requires=">=3.5",
3940
entry_points={
40-
'console_scripts': [
41-
'pytorch-fid = pytorch_fid.fid_score:main',
41+
"console_scripts": [
42+
"pytorch-fid = pytorch_fid.fid_score:main",
4243
],
4344
},
4445
install_requires=[
45-
'numpy',
46-
'pillow',
47-
'scipy',
48-
'torch>=1.0.1',
49-
'torchvision>=0.2.2'
46+
"numpy",
47+
"pillow",
48+
"scipy",
49+
"torch>=1.0.1",
50+
"torchvision>=0.2.2",
5051
],
51-
extras_require={'dev': ['flake8',
52-
'flake8-bugbear',
53-
'flake8-isort',
54-
'nox']},
52+
extras_require={
53+
"dev": ["flake8", "flake8-bugbear", "flake8-isort", "black==24.3.0", "nox"]
54+
},
5555
)

src/pytorch_fid/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.3.0'
1+
__version__ = "0.3.0"

0 commit comments

Comments
 (0)