Skip to content

Add code formatting with black #108

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

Merged
merged 3 commits into from
Mar 16, 2024
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: 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