Skip to content

Commit

Permalink
Merge pull request #930 from benjwadams/precommit_additional_fixes
Browse files Browse the repository at this point in the history
Precommit additional fixes
  • Loading branch information
benjwadams authored May 20, 2022
2 parents 4c3b637 + 1dac0ad commit c4fa475
Show file tree
Hide file tree
Showing 31 changed files with 75 additions and 369 deletions.
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[settings]
known_third_party = cf_units,cftime,httpretty,isodate,lxml,netCDF4,numpy,owslib,pendulum,pkg_resources,pygeoif,pyproj,pytest,regex,requests,setuptools,validators
known_third_party = cf_units,cftime,distutils,httpretty,isodate,lxml,netCDF4,numpy,owslib,pendulum,pkg_resources,pygeoif,pyproj,pytest,regex,requests,requests_mock,setuptools,shapely,validators
17 changes: 5 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,20 @@ repos:
- id: check-docstring-first
- id: check-added-large-files
- id: requirements-txt-fixer
- id: file-contents-sorter
files: test_requirements.txt

- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8
exclude: docs/source/conf.py
args: [--max-line-length=200, "--ignore=E203,E501,W503", "--select=select=C,E,F,W,B,B950"]

- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
additional_dependencies: [toml]
args: [--project=compliance_checker, --multi-line=3, --lines-after-imports=2, --lines-between-types=1, --trailing-comma, --force-grid-wrap=0, --use-parentheses, --line-width=88]

- repo: https://github.com/asottile/seed-isort-config
rev: v2.2.0
hooks:
- id: seed-isort-config
args: ["--profile", "black", "--filter-files"]

- repo: https://github.com/psf/black
rev: 22.3.0
Expand Down
1 change: 0 additions & 1 deletion cchecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import argparse
import sys
import warnings

from collections import defaultdict
from textwrap import dedent

Expand Down
1 change: 0 additions & 1 deletion compliance_checker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from netCDF4 import Dataset


try:
from ._version import __version__
except ImportError:
Expand Down
8 changes: 4 additions & 4 deletions compliance_checker/acdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import numpy as np
import pendulum

from cftime import num2pydate
from pygeoif import from_wkt

Expand Down Expand Up @@ -582,7 +581,7 @@ def check_time_extents(self, ds):
try:
t_min = dateparse(ds.time_coverage_start)
t_max = dateparse(ds.time_coverage_end)
except:
except (TypeError, pendulum.parsing.exceptions.ParserError):
return Result(
BaseCheck.MEDIUM,
False,
Expand Down Expand Up @@ -618,7 +617,7 @@ def check_time_extents(self, ds):
num2pydate(ds.variables[timevar][-1], ds.variables[timevar].units),
"UTC",
)
except:
except ValueError:
return Result(
BaseCheck.MEDIUM,
False,
Expand Down Expand Up @@ -829,7 +828,8 @@ def check_var_coverage_content_type(self, ds):
}
if ctype not in valid_ctypes:
msgs.append(
'coverage_content_type "%s" not in %s' % (variable, sorted(valid_ctypes))
'coverage_content_type "%s" not in %s'
% (variable, sorted(valid_ctypes))
)
results.append(
Result(
Expand Down
4 changes: 0 additions & 4 deletions compliance_checker/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,21 @@
import pprint
import re
import warnings

from collections import defaultdict
from functools import wraps
from io import StringIO

import validators

from lxml import etree
from netCDF4 import Dataset
from owslib.namespaces import Namespaces
from owslib.swe.observation.sos100 import SensorObservationService_1_0_0
from owslib.swe.sensor.sml import SensorML

import compliance_checker.cfutil as cfutil

from compliance_checker import MemoizedDataset, __version__
from compliance_checker.util import kvp_convert


# Python 3.5+ should work, also have a fallback
try:
from typing import Pattern
Expand Down
3 changes: 1 addition & 2 deletions compliance_checker/cf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from compliance_checker.cf import util
from compliance_checker.cf.appendix_d import (
dimless_vertical_coordinates_1_6,
dimless_vertical_coordinates_1_7,
)
from compliance_checker.cf.cf import CF1_6Check, CF1_7Check
from compliance_checker.cf import util


__all__ = [
"CF1_6Check",
Expand Down
13 changes: 9 additions & 4 deletions compliance_checker/cf/cf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@
# -*- coding: utf-8 -*-

from compliance_checker import cfutil # noqa: F401
from compliance_checker.base import BaseCheck, BaseNCCheck, Result, TestCtx # noqa: F401
from compliance_checker.base import ( # noqa: F401
BaseCheck,
BaseNCCheck,
Result,
TestCtx,
)
from compliance_checker.cf import util # noqa: F401
from compliance_checker.cf.appendix_d import ( # noqa: F401
dimless_vertical_coordinates_1_6,
dimless_vertical_coordinates_1_7,
no_missing_terms,
)

from compliance_checker.cf.appendix_e import cell_methods16, cell_methods17 # noqa: F401
from compliance_checker.cf.appendix_e import cell_methods16 # noqa: F401
from compliance_checker.cf.appendix_e import cell_methods17 # noqa: F401
from compliance_checker.cf.appendix_f import ellipsoid_names17 # noqa: F401
from compliance_checker.cf.appendix_f import ( # noqa: F401
ellipsoid_names17,
grid_mapping_attr_types16,
grid_mapping_attr_types17,
grid_mapping_dict16,
Expand Down
9 changes: 2 additions & 7 deletions compliance_checker/cf/cf_1_6.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
import difflib
import logging

from collections import defaultdict

import numpy as np
import regex

from cf_units import Unit

from compliance_checker import cfutil
from compliance_checker.base import BaseCheck, Result, TestCtx
from compliance_checker.cf import util
from compliance_checker.cf.appendix_c import valid_modifiers
from compliance_checker.cf.appendix_d import (
dimless_vertical_coordinates_1_6,
)
from compliance_checker.cf.appendix_d import dimless_vertical_coordinates_1_6
from compliance_checker.cf.appendix_e import cell_methods16
from compliance_checker.cf.appendix_f import (
grid_mapping_attr_types16,
grid_mapping_dict16,
)

from compliance_checker.cf.cf_base import CFNCCheck, appendix_a_base
import difflib

logger = logging.getLogger(__name__)

Expand Down
8 changes: 2 additions & 6 deletions compliance_checker/cf/cf_1_7.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import logging
import os
import sqlite3

from warnings import warn

import numpy as np
import pyproj
import regex


from compliance_checker import cfutil
from compliance_checker.base import BaseCheck, Result, TestCtx
from compliance_checker.cf.appendix_d import (
dimless_vertical_coordinates_1_7,
)
from compliance_checker.cf.appendix_d import dimless_vertical_coordinates_1_7
from compliance_checker.cf.appendix_e import cell_methods17
from compliance_checker.cf.appendix_f import (
ellipsoid_names17,
Expand All @@ -22,8 +18,8 @@
horizontal_datum_names17,
prime_meridian_names17,
)
from compliance_checker.cf.cf_base import appendix_a_base
from compliance_checker.cf.cf_1_6 import CF1_6Check
from compliance_checker.cf.cf_base import appendix_a_base

logger = logging.getLogger(__name__)

Expand Down
Loading

0 comments on commit c4fa475

Please sign in to comment.