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

Code style black #1201

Merged
merged 16 commits into from
Jun 26, 2020
Merged
Show file tree
Hide file tree
Changes from 5 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
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[tool.black]
line-length = 80
target-version = ['py36']
9 changes: 6 additions & 3 deletions tardis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,29 @@
import pyne.data

from tardis.util.colored_logger import ColoredFormatter, formatter_message

# Affiliated packages may add whatever they like to this file, but
# should keep this content at the top.
# ----------------------------------------------------------------------------
from ._astropy_init import *

# ----------------------------------------------------------------------------

from tardis.base import run_tardis
from tardis.io.util import yaml_load_config_file as yaml_load
warnings.filterwarnings('ignore', category=pyne.data.QAWarning)

warnings.filterwarnings("ignore", category=pyne.data.QAWarning)

FORMAT = "[$BOLD%(name)-20s$RESET][%(levelname)-18s] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)"
COLOR_FORMAT = formatter_message(FORMAT, True)

logging.captureWarnings(True)
logger = logging.getLogger('tardis')
logger = logging.getLogger("tardis")
logger.setLevel(logging.INFO)

console_handler = logging.StreamHandler(sys.stdout)
console_formatter = ColoredFormatter(COLOR_FORMAT)
console_handler.setFormatter(console_formatter)

logger.addHandler(console_handler)
logging.getLogger('py.warnings').addHandler(console_handler)
logging.getLogger("py.warnings").addHandler(console_handler)
65 changes: 49 additions & 16 deletions tardis/_astropy_init.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst

__all__ = ['__version__', '__githash__', 'test']
__all__ = ["__version__", "__githash__", "test"]

# this indicates whether or not we are in the package's setup.py
try:
_ASTROPY_SETUP_
except NameError:
from sys import version_info

if version_info[0] >= 3:
import builtins
else:
Expand All @@ -16,21 +17,34 @@
try:
from .version import version as __version__
except ImportError:
__version__ = ''
__version__ = ""
try:
from .version import githash as __githash__
except ImportError:
__githash__ = ''
__githash__ = ""

# set up the test command
def _get_test_runner():
import os
from astropy.tests.helper import TestRunner

return TestRunner(os.path.dirname(__file__))

def test(package=None, test_path=None, args=None, plugins=None,
verbose=False, pastebin=None, remote_data=False, pep8=False,
pdb=False, coverage=False, open_files=False, **kwargs):

def test(
package=None,
test_path=None,
args=None,
plugins=None,
verbose=False,
pastebin=None,
remote_data=False,
pep8=False,
pdb=False,
coverage=False,
open_files=False,
**kwargs,
):
"""
Run the tests using `py.test <http://pytest.org/latest>`__. A proper set
of arguments is constructed and passed to `pytest.main`_.
Expand Down Expand Up @@ -105,10 +119,20 @@ def test(package=None, test_path=None, args=None, plugins=None,
"""
test_runner = _get_test_runner()
return test_runner.run_tests(
package=package, test_path=test_path, args=args,
plugins=plugins, verbose=verbose, pastebin=pastebin,
remote_data=remote_data, pep8=pep8, pdb=pdb,
coverage=coverage, open_files=open_files, **kwargs)
package=package,
test_path=test_path,
args=args,
plugins=plugins,
verbose=verbose,
pastebin=pastebin,
remote_data=remote_data,
pep8=pep8,
pdb=pdb,
coverage=coverage,
open_files=open_files,
**kwargs,
)


if not _ASTROPY_SETUP_:
import os
Expand All @@ -118,21 +142,30 @@ def test(package=None, test_path=None, args=None, plugins=None,
# add these here so we only need to cleanup the namespace at the end
config_dir = None

if not os.environ.get('ASTROPY_SKIP_CONFIG_UPDATE', False):
if not os.environ.get("ASTROPY_SKIP_CONFIG_UPDATE", False):
config_dir = os.path.dirname(__file__)
config_template = os.path.join(config_dir, __package__ + ".cfg")
if os.path.isfile(config_template):
try:
config.configuration.update_default_config(
__package__, config_dir, version=__version__)
__package__, config_dir, version=__version__
)
except TypeError as orig_error:
try:
config.configuration.update_default_config(
__package__, config_dir)
__package__, config_dir
)
except config.configuration.ConfigurationDefaultMissingError as e:
wmsg = (e.args[0] + " Cannot install default profile. If you are "
"importing from source, this is expected.")
warn(config.configuration.ConfigurationDefaultMissingWarning(wmsg))
wmsg = (
e.args[0]
+ " Cannot install default profile. If you are "
"importing from source, this is expected."
)
warn(
config.configuration.ConfigurationDefaultMissingWarning(
wmsg
)
)
del e
except:
raise orig_error
Loading