Skip to content

Commit

Permalink
Merge pull request #797 from jdavies-st/flake8-f-w
Browse files Browse the repository at this point in the history
Add F and W flags to automated flake8 checks in setup.cfg
  • Loading branch information
eslavich authored May 15, 2020
2 parents a46f451 + 26039d8 commit 520a361
Show file tree
Hide file tree
Showing 47 changed files with 121 additions and 228 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
- Add option to ``asdf.open`` and ``fits_embed.AsdfInFits.open``
that disables validation on read. [#792]

- Fix bugs and code style found by adding F and W ``flake8`` checks. [#797]

2.6.1 (unreleased)
------------------

Expand Down
19 changes: 3 additions & 16 deletions asdf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,15 @@
# Affiliated packages may add whatever they like to this file, but
# should keep this content at the top.
# ----------------------------------------------------------------------------
from ._internal_init import *
from ._internal_init import __version__, __githash__, test
# ----------------------------------------------------------------------------

__all__ = [
'AsdfFile', 'CustomType', 'AsdfExtension', 'Stream', 'open', 'test',
'commands', 'IntegerType', 'ExternalArrayReference', 'info'
'commands', 'IntegerType', 'ExternalArrayReference', 'info', '__version__',
'__githash__', 'ValidationError'
]

try:
import yaml as _
except ImportError:
raise ImportError("asdf requires pyyaml")

try:
import jsonschema as _
except ImportError:
raise ImportError("asdf requires jsonschema")

try:
import numpy as _
except ImportError:
raise ImportError("asdf requires numpy")

from .asdf import AsdfFile, open_asdf
from .types import CustomType
Expand Down
4 changes: 0 additions & 4 deletions asdf/_internal_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@ def test(package=None, test_path=None, args=None, plugins=None,
explicitly updating the package template.
"""
try:
import astropy
except ImportError:
raise ImportError("Running the tests requires astropy")

test_runner = _get_test_runner()
return test_runner.run_tests(
Expand Down
2 changes: 0 additions & 2 deletions asdf/asdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
import io
import os
import time
import re
import copy
import datetime
import warnings
import importlib
from pkg_resources import parse_version

import numpy as np
Expand Down
6 changes: 4 additions & 2 deletions asdf/asdftypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
from .exceptions import AsdfDeprecationWarning
# This is not exhaustive, but represents the public API
from .versioning import join_tag_version, split_tag_version
from .types import (AsdfType, CustomType, format_tag, ExtensionTypeMeta,
_all_asdftypes)
from .types import (AsdfType, CustomType, format_tag, ExtensionTypeMeta)

__all__ = ["join_tag_version", "split_tag_version", "AsdfType", "CustomType",
"format_tag", "ExtensionTypeMeta"]

warnings.warn(
"The module asdf.asdftypes has been deprecated and will be removed in 3.0. "
Expand Down
1 change: 0 additions & 1 deletion asdf/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from .compat.numpycompat import NUMPY_LT_1_7
from . import constants
from . import generic_io
from . import stream
from . import treeutil
from . import util
from . import yamlutil
Expand Down
25 changes: 16 additions & 9 deletions asdf/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@

import importlib

from .exploded import *
from .to_yaml import *
from .defragment import *
from .diff import *
from .tags import *
from .extension import *
from .info import *
from .exploded import implode, explode
from .to_yaml import to_yaml
from .defragment import defragment
from .diff import diff
from .tags import list_tags
from .extension import find_extensions
from .info import info


__all__ = ['implode', 'explode', 'to_yaml', 'defragment', 'diff', 'list_tags',
'find_extensions', 'info']


# Extracting ASDF-in-FITS files requires Astropy
if importlib.util.find_spec('astropy'):
from .extract import *
from .remove_hdu import *
from .extract import extract_file
from .remove_hdu import remove_hdu

__all__ += ['extract_file', 'remove_hdu']
3 changes: 0 additions & 3 deletions asdf/commands/defragment.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
Defragment command.
"""


import os

import asdf
from .main import Command
from .. import AsdfFile
Expand Down
4 changes: 0 additions & 4 deletions asdf/commands/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
Implementation of command for displaying differences between two ASDF files.
"""


import os
import sys
from numpy import array_equal
try:
Expand All @@ -30,8 +28,6 @@

import asdf
from .main import Command
from .. import AsdfFile
from .. import treeutil
from ..tagged import Tagged
from ..util import human_list
from ..tags.core.ndarray import NDArrayType
Expand Down
1 change: 1 addition & 0 deletions asdf/commands/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from .main import Command

__all__ = ['find_extensions']

class QueryExtension(Command): # pragma: no cover
"""This class is the plugin implementation for the asdftool runner."""
Expand Down
3 changes: 0 additions & 3 deletions asdf/commands/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
Implementation of command for converting ASDF-in-FITS to standalone ASDF file.
"""

import sys

import asdf
from asdf import AsdfFile
from asdf.fits_embed import AsdfInFits

from .main import Command
Expand Down
2 changes: 0 additions & 2 deletions asdf/commands/remove_hdu.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
Implementation of command for removing ASDF HDU from ASDF-in-FITS file.
"""

import sys

from astropy.io import fits

from .main import Command
Expand Down
8 changes: 3 additions & 5 deletions asdf/commands/tests/test_defragment.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
# -*- coding: utf-8 -*-


import os
import sys

import numpy as np
import pytest

import asdf
from ... import AsdfFile
from .. import main
from ...tests.helpers import get_file_sizes, assert_tree_match
from asdf import AsdfFile
from asdf.commands import main
from asdf.tests.helpers import get_file_sizes, assert_tree_match


def _test_defragment(tmpdir, codec):
Expand Down
9 changes: 2 additions & 7 deletions asdf/commands/tests/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@
# -*- coding: utf-8 -*-


import os
import io
from functools import partial

import numpy as np
import pytest

from ... import AsdfFile
from ...tests import helpers

from .. import main, diff

from asdf.tests import helpers
from asdf.commands import main, diff
from . import data as test_data
get_test_data_path = partial(helpers.get_test_data_path, module=test_data)

Expand Down
11 changes: 3 additions & 8 deletions asdf/conftest.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
# -*- coding: utf-8 -*-
# this contains imports plugins that configure py.test for asdf tests.
# by importing them here in conftest.py they are discoverable by py.test

# This contains pytest fixtures used in asdf tests.
# by importing them here in conftest.py they are discoverable by pytest
# no matter how it is invoked within the source tree.

import os

import pytest

from .extern.RangeHTTPServer import RangeHTTPRequestHandler

# This is to figure out the affiliated package version, rather than
# using Astropy's
from . import version
from .tests.httpserver import HTTPServer, RangeHTTPServer


Expand Down
2 changes: 0 additions & 2 deletions asdf/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import warnings
from pkg_resources import iter_entry_points

import importlib

from . import types
from . import resolver
from .util import get_class_name
Expand Down
43 changes: 0 additions & 43 deletions asdf/extern/decorators.py

This file was deleted.

1 change: 0 additions & 1 deletion asdf/fits_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

try:
from astropy.io import fits
from astropy.io.fits import Column, BinTableHDU
except ImportError:
raise ImportError("AsdfInFits requires astropy")

Expand Down
3 changes: 0 additions & 3 deletions asdf/schema.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
# -*- coding: utf-8 -*-

import os
import json
import datetime
import warnings
import copy
from numbers import Integral
from functools import lru_cache
from collections import OrderedDict
from collections.abc import Mapping
from urllib import parse as urlparse

from jsonschema import validators as mvalidators
Expand All @@ -23,7 +21,6 @@
from . import reference
from . import treeutil
from . import util
from .extension import default_extensions
from .compat.jsonschemacompat import JSONSCHEMA_LT_3
from . import extension
from .exceptions import AsdfDeprecationWarning
Expand Down
6 changes: 0 additions & 6 deletions asdf/tags/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
# -*- coding: utf-8 -*-


# TODO: Import entire tree automatically and make these work like "plugins"?

from . import core
18 changes: 11 additions & 7 deletions asdf/tags/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@
class AsdfObject(dict):
pass

from .constant import ConstantType
from .ndarray import NDArrayType
from .complex import ComplexType
from .integer import IntegerType
from .external_reference import ExternalArrayReference


__all__ = ['AsdfObject', 'Software', 'HistoryEntry', 'ExtensionMetadata',
'SubclassMetadata', 'ConstantType', 'NDArrayType', 'ComplexType',
'IntegerType', 'ExternalArrayReference']


class AsdfObjectType(AsdfType):
name = 'core/asdf'
Expand Down Expand Up @@ -56,10 +67,3 @@ def to_tree(cls, node, ctx):
class SubclassMetadata(dict, AsdfType):
name = 'core/subclass_metadata'
version = '1.0.0'


from .constant import ConstantType
from .ndarray import NDArrayType
from .complex import ComplexType
from .integer import IntegerType
from .external_reference import ExternalArrayReference
1 change: 0 additions & 1 deletion asdf/tags/core/ndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from ...types import AsdfType
from ... import schema
from ... import util
from ... import yamlutil


_datatype_names = {
Expand Down
4 changes: 1 addition & 3 deletions asdf/tags/core/tests/test_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ def test_valid_complex(valid):
'nan+4j'
])
def test_valid_nan_complex(valid):

with asdf.open(make_complex_asdf(valid)) as af:
# Don't compare values since NANs are never equal
with asdf.open(make_complex_asdf(valid)):
pass


Expand Down
Loading

0 comments on commit 520a361

Please sign in to comment.