Skip to content

Commit

Permalink
Merge pull request #222 from xylar/remove-future-imports
Browse files Browse the repository at this point in the history
Clean-up on imports and pre-commit
  • Loading branch information
xylar authored Dec 21, 2024
2 parents 2183682 + d6fdd75 commit c06adaf
Show file tree
Hide file tree
Showing 18 changed files with 31 additions and 83 deletions.
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ repos:
rev: 5.13.2
hooks:
- id: isort
exclude: "geometric_features/__init__.py"

# Can run individually with `flynt [file]` or `flynt [source]`
- repo: https://github.com/ikamensh/flynt
Expand Down
7 changes: 3 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import os
from datetime import date

import geometric_features
from geometric_features.docs.parse_quick_start import build_quick_start
from geometric_features.version import __version__

# -- General configuration ------------------------------------------------

Expand Down Expand Up @@ -72,9 +71,9 @@
# built documents.
#
# The short X.Y version.
version = geometric_features.__version__
version = __version__
# The full version, including alpha/beta/rc tags.
release = geometric_features.__version__
release = __version__

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
4 changes: 0 additions & 4 deletions examples/setup_antarctic_basins.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
This script combines Antarctic basins into a single feature file.
"""

# stuff to make scipts work for python 2 and python 3
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import matplotlib.pyplot as plt

from geometric_features import GeometricFeatures
Expand Down
4 changes: 0 additions & 4 deletions examples/setup_extended_antarctic_basins.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
into a single feature file.
"""

# stuff to make scipts work for python 2 and python 3
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import matplotlib.pyplot as plt

from geometric_features import FeatureCollection, GeometricFeatures
Expand Down
4 changes: 0 additions & 4 deletions examples/setup_ice_shelves.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
This script creates region groups for ice shelves
"""

# stuff to make scipts work for python 2 and python 3
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import matplotlib.pyplot as plt

from geometric_features import FeatureCollection, GeometricFeatures
Expand Down
4 changes: 0 additions & 4 deletions examples/setup_ocean_critical_passages.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
This script combines transects defining cricial passages.
"""

# stuff to make scipts work for python 2 and python 3
from __future__ import (absolute_import, division, print_function,
unicode_literals)

from geometric_features import GeometricFeatures

# create a GeometricFeatures object that points to a local cache of geometric
Expand Down
4 changes: 0 additions & 4 deletions examples/setup_ocean_land_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
up sub-ice-shelf cavities in the ocean around Antarctica.
"""

# stuff to make scipts work for python 2 and python 3
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import matplotlib.pyplot as plt

from geometric_features import GeometricFeatures
Expand Down
4 changes: 0 additions & 4 deletions examples/setup_ocean_region_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
regions.
"""

# stuff to make scipts work for python 2 and python 3
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import copy

import matplotlib.pyplot as plt
Expand Down
4 changes: 0 additions & 4 deletions examples/setup_ocean_standard_transport_sections.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
all of which have the "standard_transport_sections" tag.
"""

# stuff to make scipts work for python 2 and python 3
from __future__ import (absolute_import, division, print_function,
unicode_literals)

from geometric_features import GeometricFeatures

# create a GeometricFeatures object that points to a local cache of geometric
Expand Down
22 changes: 7 additions & 15 deletions geometric_features/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
from __future__ import absolute_import, division, print_function, \
unicode_literals

from geometric_features.__main__ import (combine_features, difference_features,
fix_features_at_antimeridian,
merge_features, plot_features,
set_group_name, simplify_features,
split_features, tag_features)
from geometric_features.feature_collection import (FeatureCollection,
read_feature_collection)
from geometric_features.geometric_features import GeometricFeatures

from geometric_features.feature_collection import FeatureCollection, \
read_feature_collection

from geometric_features.__main__ import combine_features, difference_features, \
fix_features_at_antimeridian, merge_features, plot_features, \
set_group_name, split_features, simplify_features, tag_features

from geometric_features.utils import write_feature_names_and_tags


__version_info__ = (1, 6, 0)
__version__ = '.'.join(str(vi) for vi in __version_info__)
28 changes: 13 additions & 15 deletions geometric_features/__main__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import argparse
import os

import geometric_features
from geometric_features import GeometricFeatures
from geometric_features.feature_collection import (FeatureCollection,
read_feature_collection)
from geometric_features.geometric_features import GeometricFeatures
from geometric_features.version import __version__


def combine_features():
Expand All @@ -28,7 +25,7 @@ def combine_features():
metavar="PATH", default="features.geojson")
parser.add_argument('-v', '--version',
action='version',
version=f'geometric_features {geometric_features.__version__}',
version=f'geometric_features {__version__}',
help="Show version number and exit")

args = parser.parse_args()
Expand Down Expand Up @@ -57,7 +54,7 @@ def difference_features():
metavar="PATH", default="features.geojson")
parser.add_argument('-v', '--version',
action='version',
version=f'geometric_features {geometric_features.__version__}',
version=f'geometric_features {__version__}',
help="Show version number and exit")

args = parser.parse_args()
Expand All @@ -82,7 +79,7 @@ def fix_features_at_antimeridian():
metavar="PATH", default="features.geojson")
parser.add_argument('-v', '--version',
action='version',
version=f'geometric_features {geometric_features.__version__}',
version=f'geometric_features {__version__}',
help="Show version number and exit")

args = parser.parse_args()
Expand Down Expand Up @@ -124,7 +121,7 @@ def merge_features():
metavar="PATH")
parser.add_argument('-v', '--version',
action='version',
version=f'geometric_features {geometric_features.__version__}',
version=f'geometric_features {__version__}',
help="Show version number and exit")

args = parser.parse_args()
Expand Down Expand Up @@ -169,7 +166,7 @@ def plot_features():
" (0.0 indicates skip subdivision)")
parser.add_argument('-v', '--version',
action='version',
version=f'geometric_features {geometric_features.__version__}',
version=f'geometric_features {__version__}',
help="Show version number and exit")

args = parser.parse_args()
Expand All @@ -191,7 +188,8 @@ def plot_features():
figsize = (12, 9)
fig = fc.plot(mapType, args.max_length, figsize)

plotFileName = f'{os.path.splitext(args.feature_file)[0]}_{mapType}.png'
plotFileName = \
f'{os.path.splitext(args.feature_file)[0]}_{mapType}.png'

fig.savefig(plotFileName)

Expand All @@ -211,7 +209,7 @@ def set_group_name():
required=True)
parser.add_argument('-v', '--version',
action='version',
version=f'geometric_features {geometric_features.__version__}',
version=f'geometric_features {__version__}',
help="Show version number and exit")

args = parser.parse_args()
Expand Down Expand Up @@ -240,7 +238,7 @@ def simplify_features():
metavar="PATH", default="features.geojson")
parser.add_argument('-v', '--version',
action='version',
version=f'geometric_features {geometric_features.__version__}',
version=f'geometric_features {__version__}',
help="Show version number and exit")
args = parser.parse_args()

Expand All @@ -265,7 +263,7 @@ def split_features():
metavar="PATH", default="./geometric_data")
parser.add_argument('-v', '--version',
action='version',
version=f'geometric_features {geometric_features.__version__}',
version=f'geometric_features {__version__}',
help="Show version number and exit")
args = parser.parse_args()

Expand Down Expand Up @@ -294,7 +292,7 @@ def tag_features():
metavar="PATH", default="features.geojson")
parser.add_argument('-v', '--version',
action='version',
version=f'geometric_features {geometric_features.__version__}',
version=f'geometric_features {__version__}',
help="Show version number and exit")
args = parser.parse_args()

Expand Down
3 changes: 0 additions & 3 deletions geometric_features/download.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import os
from urllib.request import pathname2url

Expand Down
3 changes: 0 additions & 3 deletions geometric_features/feature_collection.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import json

try:
Expand Down
10 changes: 4 additions & 6 deletions geometric_features/geometric_features.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import json
import os
from importlib.resources import files as imp_res_files

import geometric_features
from geometric_features.download import download_files
from geometric_features.feature_collection import (FeatureCollection,
read_feature_collection)
from geometric_features.version import __version__


class GeometricFeatures(object):
Expand Down Expand Up @@ -57,7 +54,7 @@ def __init__(self, cacheLocation=None, remoteBranchOrTag=None):
else:
self.cacheLocation = cacheLocation
if remoteBranchOrTag is None:
self.remoteBranch = geometric_features.__version__
self.remoteBranch = __version__
else:
self.remoteBranch = remoteBranchOrTag

Expand Down Expand Up @@ -262,7 +259,8 @@ def _get_feature_names(self, componentName, objectType, featureNames,
component = self.allFeaturesAndTags[componentName]

if objectType not in component:
raise KeyError(f'invalid object {objectType} in component {componentName}')
raise KeyError(
f'invalid object {objectType} in component {componentName}')

availableFeaturesAndTags = component[objectType]

Expand Down
3 changes: 0 additions & 3 deletions geometric_features/plot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import cartopy.crs
import cartopy.feature
import matplotlib.pyplot as plt
Expand Down
3 changes: 0 additions & 3 deletions geometric_features/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import datetime
import glob
import json
Expand Down
2 changes: 2 additions & 0 deletions geometric_features/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__version_info__ = (1, 6, 0)
__version__ = '.'.join(str(vi) for vi in __version_info__)
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from setuptools import find_packages, setup

here = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(here, 'geometric_features', '__init__.py')) as f:
with open(os.path.join(here, 'geometric_features', 'version.py')) as f:
init_file = f.read()

version = re.search(r'{}\s*=\s*[(]([^)]*)[)]'.format('__version_info__'),
Expand Down Expand Up @@ -49,7 +49,7 @@
'difference_features = '
'geometric_features.__main__:difference_features',
'fix_features_at_antimeridian = '
'geometric_features.__main__:fix_features_at_antimeridian',
'geometric_features.__main__:fix_features_at_antimeridian', # noqa: E501
'merge_features = '
'geometric_features.__main__:merge_features',
'plot_features = '
Expand Down

0 comments on commit c06adaf

Please sign in to comment.