Skip to content
This repository has been archived by the owner on Nov 18, 2024. It is now read-only.

Commit

Permalink
RF: pre-commit all files (excluding versioneer related)
Browse files Browse the repository at this point in the history
  • Loading branch information
yarikoptic committed Oct 8, 2019
1 parent 563a949 commit 9ce9165
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 45 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ dist/
pip-wheel-metadata/
sandbox/
venvs/

10 changes: 5 additions & 5 deletions dandi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from . import _version

__version__ = _version.get_versions()['version']
__version__ = _version.get_versions()["version"]


#
Expand All @@ -13,13 +13,13 @@
def get_logger(name=None):
"""Return a logger to use
"""
return logging.getLogger('dandi' + ('.%s' % name if name else ''))
return logging.getLogger("dandi" + (".%s" % name if name else ""))


_DEFAULT_LOG_FORMAT = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
_DEFAULT_LOG_FORMAT = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"

lgr = get_logger()
# Basic settings for output, for now just basic
lgr.setLevel(logging.INFO)
FORMAT = '%(asctime)-15s [%(levelname)8s] %(message)s'
logging.basicConfig(format=FORMAT)
FORMAT = "%(asctime)-15s [%(levelname)8s] %(message)s"
logging.basicConfig(format=FORMAT)
2 changes: 0 additions & 2 deletions dandi/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@
too cubmersome. yoh thinks he saw a bit more lightweight somewhere.
e.g. girder-client
"""


5 changes: 1 addition & 4 deletions dandi/cli/tests/test_command.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
from ..command import (
ls,
validate,
)
from ..command import ls, validate

from click.testing import CliRunner
import pytest
Expand Down
2 changes: 1 addition & 1 deletion dandi/support/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""
Various utilities, typically to support use of external modules etc
"""
"""
22 changes: 8 additions & 14 deletions dandi/tests/fixtures.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,30 @@
from datetime import (
datetime,
)
from datetime import datetime
from dateutil.tz import tzutc

import pynwb
from ..pynwb_utils import (
metadata_fields,
)
from ..pynwb_utils import metadata_fields

import pytest

# TODO: move into some common fixtures. We might produce a number of files
# and also carry some small ones directly in git for regression testing
@pytest.fixture(scope='session')
@pytest.fixture(scope="session")
def simple1_nwb_metadata(tmpdir_factory):
# very simple assignment with the same values as the key with 1 as suffix
metadata = {f: "{}1".format(f) for f in metadata_fields}
# tune specific ones:
# Needs an explicit time zone since otherwise pynwb would add one
# But then comparison breaks anyways any ways yoh have tried to set it
# for datetime.now. Taking example from pynwb tests
metadata['session_start_time'] = datetime(2017, 4, 15, 12, tzinfo=tzutc())
metadata['keywords'] = ['keyword1', 'keyword 2']
metadata["session_start_time"] = datetime(2017, 4, 15, 12, tzinfo=tzutc())
metadata["keywords"] = ["keyword1", "keyword 2"]
return metadata


@pytest.fixture(scope='session')
@pytest.fixture(scope="session")
def simple1_nwb(simple1_nwb_metadata, tmpdir_factory):
filename = str(tmpdir_factory.mktemp('data').join('simple1.nwb'))
filename = str(tmpdir_factory.mktemp("data").join("simple1.nwb"))
nwbfile = pynwb.NWBFile(**simple1_nwb_metadata)
with pynwb.NWBHDF5IO(filename, 'w') as io:
with pynwb.NWBHDF5IO(filename, "w") as io:
io.write(nwbfile, cache_spec=False)
return filename


13 changes: 5 additions & 8 deletions dandi/tests/test_pynwb_utils.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
import pynwb

from ..pynwb_utils import (
get_metadata,
)

from ..pynwb_utils import get_metadata


def test_get_metadata(simple1_nwb, simple1_nwb_metadata):
target_metadata = simple1_nwb_metadata.copy()
# we will also get some counts
target_metadata['number_of_electrodes'] = 0
target_metadata['number_of_units'] = 0
target_metadata["number_of_electrodes"] = 0
target_metadata["number_of_units"] = 0
# subject_id is also nohow specified in that file yet
target_metadata['subject_id'] = None
target_metadata["subject_id"] = None
assert target_metadata == get_metadata(str(simple1_nwb))


def test_pynwb_io(simple1_nwb):
# To verify that our dependencies spec is sufficient to avoid
# stepping into known pynwb/hdmf issues
with pynwb.NWBHDF5IO(str(simple1_nwb), 'r', load_namespaces=True) as reader:
with pynwb.NWBHDF5IO(str(simple1_nwb), "r", load_namespaces=True) as reader:
nwbfile = reader.read()
assert repr(nwbfile)
assert str(nwbfile)
11 changes: 8 additions & 3 deletions dandi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,21 @@ def setup_exceptionhook(ipython=False):

def _pdb_excepthook(type, value, tb):
import traceback

traceback.print_exception(type, value, tb)
print()
if is_interactive():
import pdb

pdb.post_mortem(tb)

if ipython:
from IPython.core import ultratb
sys.excepthook = ultratb.FormattedTB(mode='Verbose',
# color_scheme='Linux',
call_pdb=is_interactive())

sys.excepthook = ultratb.FormattedTB(
mode="Verbose",
# color_scheme='Linux',
call_pdb=is_interactive(),
)
else:
sys.excepthook = _pdb_excepthook
14 changes: 7 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
import sys

from setuptools import setup

try:
import versioneer

setup_kw = {
'version': versioneer.get_version(),
'cmdclass': versioneer.get_cmdclass()
"version": versioneer.get_version(),
"cmdclass": versioneer.get_cmdclass(),
}
except ImportError:
# see https://github.com/warner/python-versioneer/issues/192
Expand All @@ -26,11 +28,9 @@
# Give setuptools a hint to complain if it's too old a version
# 30.3.0 allows us to put most metadata in setup.cfg
# Should match pyproject.toml
SETUP_REQUIRES = ['setuptools >= 30.3.0']
SETUP_REQUIRES = ["setuptools >= 30.3.0"]
# This enables setuptools to install wheel on-the-fly
SETUP_REQUIRES += ['wheel'] if 'bdist_wheel' in sys.argv else []
SETUP_REQUIRES += ["wheel"] if "bdist_wheel" in sys.argv else []

if __name__ == "__main__":
setup(name='dandi',
setup_requires=SETUP_REQUIRES,
**setup_kw)
setup(name="dandi", setup_requires=SETUP_REQUIRES, **setup_kw)

0 comments on commit 9ce9165

Please sign in to comment.