Skip to content

Commit

Permalink
Merge pull request #108 from mseitzer/black
Browse files Browse the repository at this point in the history
Add code formatting with black
  • Loading branch information
mseitzer authored Mar 16, 2024
2 parents 46e6974 + af953a9 commit b9c1811
Show file tree
Hide file tree
Showing 9 changed files with 226 additions and 189 deletions.
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
select = F,W,E,I,B,B9
ignore = W503,E203,B950
max-line-length = 88
27 changes: 15 additions & 12 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
import nox

LOCATIONS = ('src/', 'tests/', 'noxfile.py', 'setup.py')
LOCATIONS = ("src/", "tests/", "noxfile.py", "setup.py")


@nox.session
def lint(session):
session.install('flake8')
session.install('flake8-bugbear')
session.install('flake8-isort')
session.install("flake8")
session.install("flake8-bugbear")
session.install("flake8-isort")
session.install("black==24.3.0")

args = session.posargs or LOCATIONS
session.run('flake8', *args)
session.run("flake8", *args)
session.run("black", "--check", "--diff", *args)


@nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12"])
def tests(session):
session.install(
'torch==2.2.1',
'torchvision',
'--index-url', 'https://download.pytorch.org/whl/cpu'
"torch==2.2.1",
"torchvision",
"--index-url",
"https://download.pytorch.org/whl/cpu",
)
session.install('.')
session.install('pytest')
session.install('pytest-mock')
session.run('pytest', *session.posargs)
session.install(".")
session.install("pytest")
session.install("pytest-mock")
session.run("pytest", *session.posargs)
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[tool.black]
target-version = ["py311"]

[tool.isort]
profile = "black"
line_length = 88
multi_line_output = 3
8 changes: 0 additions & 8 deletions setup.cfg

This file was deleted.

56 changes: 28 additions & 28 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,51 @@

def read(rel_path):
base_path = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(base_path, rel_path), 'r') as f:
with open(os.path.join(base_path, rel_path), "r") as f:
return f.read()


def get_version(rel_path):
for line in read(rel_path).splitlines():
if line.startswith('__version__'):
if line.startswith("__version__"):
# __version__ = "0.9"
delim = '"' if '"' in line else "'"
return line.split(delim)[1]

raise RuntimeError('Unable to find version string.')
raise RuntimeError("Unable to find version string.")


if __name__ == '__main__':
if __name__ == "__main__":
setuptools.setup(
name='pytorch-fid',
version=get_version(os.path.join('src', 'pytorch_fid', '__init__.py')),
author='Max Seitzer',
description=('Package for calculating Frechet Inception Distance (FID)'
' using PyTorch'),
long_description=read('README.md'),
long_description_content_type='text/markdown',
url='https://github.com/mseitzer/pytorch-fid',
package_dir={'': 'src'},
packages=setuptools.find_packages(where='src'),
name="pytorch-fid",
version=get_version(os.path.join("src", "pytorch_fid", "__init__.py")),
author="Max Seitzer",
description=(
"Package for calculating Frechet Inception Distance (FID)" " using PyTorch"
),
long_description=read("README.md"),
long_description_content_type="text/markdown",
url="https://github.com/mseitzer/pytorch-fid",
package_dir={"": "src"},
packages=setuptools.find_packages(where="src"),
classifiers=[
'Programming Language :: Python :: 3',
'License :: OSI Approved :: Apache Software License',
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
],
python_requires='>=3.5',
python_requires=">=3.5",
entry_points={
'console_scripts': [
'pytorch-fid = pytorch_fid.fid_score:main',
"console_scripts": [
"pytorch-fid = pytorch_fid.fid_score:main",
],
},
install_requires=[
'numpy',
'pillow',
'scipy',
'torch>=1.0.1',
'torchvision>=0.2.2'
"numpy",
"pillow",
"scipy",
"torch>=1.0.1",
"torchvision>=0.2.2",
],
extras_require={'dev': ['flake8',
'flake8-bugbear',
'flake8-isort',
'nox']},
extras_require={
"dev": ["flake8", "flake8-bugbear", "flake8-isort", "black==24.3.0", "nox"]
},
)
2 changes: 1 addition & 1 deletion src/pytorch_fid/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.3.0'
__version__ = "0.3.0"
Loading

0 comments on commit b9c1811

Please sign in to comment.