Skip to content

Commit

Permalink
Enable and run pyupgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
VeckoTheGecko committed Aug 27, 2024
1 parent 85ffd62 commit 599a99b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions parcels/fieldset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ def from_modulefile(cls, filename, modulename="create_fieldset", **kwargs):
"""
# check if filename exists
if not os.path.exists(filename):
raise IOError(f"FieldSet module file {filename} does not exist")
raise OSError(f"FieldSet module file {filename} does not exist")

# Importing the source file directly (following https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly)
spec = importlib.util.spec_from_file_location(modulename, filename)
Expand All @@ -1318,10 +1318,10 @@ def from_modulefile(cls, filename, modulename="create_fieldset", **kwargs):
spec.loader.exec_module(fieldset_module)

if not hasattr(fieldset_module, modulename):
raise IOError(f"{filename} does not contain a {modulename} function")
raise OSError(f"{filename} does not contain a {modulename} function")
fieldset = getattr(fieldset_module, modulename)(**kwargs)
if not isinstance(fieldset, FieldSet):
raise IOError(f"Module {filename}.{modulename} does not return a FieldSet object")
raise OSError(f"Module {filename}.{modulename} does not return a FieldSet object")
return fieldset

def get_fields(self):
Expand Down
2 changes: 1 addition & 1 deletion parcels/particleset.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def ArrayClass_init(self, *args, **kwargs):
lon = np.empty(shape=0) if lon is None else convert_to_flat_array(lon)
lat = np.empty(shape=0) if lat is None else convert_to_flat_array(lat)

if isinstance(pid_orig, (type(None), type(False))):
if isinstance(pid_orig, (type(None), bool)):
pid_orig = np.arange(lon.size)

if depth is None:
Expand Down
3 changes: 1 addition & 2 deletions parcels/tools/exampledata_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
from datetime import datetime, timedelta
from pathlib import Path
from typing import List
from urllib.request import urlretrieve

import platformdirs
Expand Down Expand Up @@ -96,7 +95,7 @@ def get_data_home(data_home=None):
return data_home


def list_example_datasets() -> List[str]:
def list_example_datasets() -> list[str]:
"""List the available example datasets.
Use :func:`download_example_dataset` to download one of the datasets.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ select = [
"F", # pyflakes
"I", # isort
"B", # Bugbear
# "UP", # pyupgrade
"UP", # pyupgrade
"LOG", # logging
"ICN", # import conventions
"G", # logging-format
Expand Down

0 comments on commit 599a99b

Please sign in to comment.