Skip to content

Commit

Permalink
More fixes for ruff F
Browse files Browse the repository at this point in the history
  • Loading branch information
dstansby committed Apr 25, 2023
1 parent aef4ba3 commit e56d94d
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion benchmarks/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ def mem_parse_time():


def peakmem_parse_time():
t = parse_time('1995-12-31 23:59:60')
parse_time('1995-12-31 23:59:60')
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@
# a list of builtin themes.

from sunpy_sphinx_theme.conf import * # NOQA
from sunpy_sphinx_theme.conf import png_icon # NOQA

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Expand Down
12 changes: 6 additions & 6 deletions examples/developer_tools/remote_data_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@manager.require('test_file',
['http://data.sunpy.org/sample-data/predicted-sunspot-radio-flux.txt'],
'4c85b04a5528aa97eb84a087450eda0421c71833820576330bba148564089b11')
def test_function():
def test_function_1():
pass

##############################################################################
Expand All @@ -35,27 +35,27 @@ def test_function():
@manager.require('test_file',
['http://data.sunpy.org/sample-data/predicted-sunspot-radio-flux.txt'],
'4c85b04a5528aa97eb84a087450eda0421c71833820576330bba148564089b11')
def test_function():
def test_function_2():
return manager.get('test_file')

##############################################################################
# The first time the function is called, the file will be downloaded.
# During subsequent calls, no downloading will take place.


print(test_function()) # The file will be downloaded
print(test_function()) # No downloading here
print(test_function_2()) # The file will be downloaded
print(test_function_2()) # No downloading here

##############################################################################
# In case the user wants to skip the hash check, there is a helper context manager
# `~sunpy.data.data_manager.manager.DataManager.skip_hash_check`.

with manager.skip_hash_check():
print(test_function())
print(test_function_2())

##############################################################################
# If the user knows the function is going to use a file and want to replace it with another version
# they can do that too.

with manager.override_file('test_file', 'http://data.sunpy.org/sample-data/AIA20110319_105400_0171.fits'):
print(test_function())
print(test_function_2())
15 changes: 10 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,23 @@ extend-ignore = [
"warnings.warn".msg = "Use sunpy specific warning helpers warn_* from sunpy.utils.exceptions"

[tool.ruff.per-file-ignores]
"setup.py" = ["INP001"] # Part of configuration, not a package.
# Part of configuration, not a package.
"setup.py" = ["INP001"]
"conftest.py" = ["INP001"]
# implicit-namespace-package. The examples are not a package.
"docs/*.py" = ["INP001"]

"__init__.py" = ["E402", "F401", "F403"]
"test_*.py" = ["B011", "D", "E402", "PGH001", "S101"]
"conftest.py" = ["INP001"] # Part of configuration, not a package.
"docs/*.py" = [
"INP001", # implicit-namespace-package. The examples are not a package.
]

# Need to import clients to register them, but don't use them in file
"sunpy/net/__init__.py" = ["F811"]
# These files are allowed to use warnings.warn
"sunpy/util/exceptions.py" = ["TID251"]
"sunpy/util/tests/test_logger.py" = ["TID251"]
"sunpy/util/decorators.py" = ["TID251"]
# Notebook config for binder uses undefined variable
".jupyter/jupyter_notebook_config.py" = ["F821"]

[tool.ruff.pydocstyle]
convention = "numpy"
2 changes: 1 addition & 1 deletion sunpy/io/file_tools.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from _file_tools import * # noqa: F401
from _file_tools import * # noqa: F403

from sunpy.util.exceptions import warn_deprecated
from . import _file_tools
Expand Down
2 changes: 1 addition & 1 deletion sunpy/io/jp2.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from _jp2 import * # noqa: F401
from _jp2 import * # noqa: F403

from sunpy.util.exceptions import warn_deprecated
from . import _jp2
Expand Down
2 changes: 1 addition & 1 deletion sunpy/net/dataretriever/sources/tests/test_goes_ud.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def test_resolution_attrs(LCClient):

# check is incorrect resolution attrs passed
with pytest.raises(RuntimeError):
qr_wrong_resolution = LCClient.search(Time('2012/10/4 20:20', '2012/10/4 21:00'), Instrument('XRS'), a.Resolution.ctime)
LCClient.search(Time('2012/10/4 20:20', '2012/10/4 21:00'), Instrument('XRS'), a.Resolution.ctime)


@pytest.mark.remote_data
Expand Down
9 changes: 2 additions & 7 deletions sunpy/net/jsoc/jsoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,13 +483,8 @@ def get_request(self, requests, path=None, overwrite=False, progress=True,
# Private communication from JSOC say we should not use more than one connection.
max_splits = kwargs.get('max_splits', 1)
if max_splits != 1:
<<<<<<< HEAD
log.info(f"Setting max_splits to it's maximum allowed value of 1 for requests made by the JSOCClient.")
max_splits = 1
=======
log.info("Setting max_splits to it's maximum allowed value of 1 for requests made by the JSOCClient.")
kwargs['max_splits'] = 1
>>>>>>> d7f3edba9 (Ruff: Fix F)
max_splits = 1

# Convert Responses to a list if not already
if isinstance(requests, str) or not isiterable(requests):
Expand Down Expand Up @@ -538,7 +533,7 @@ def get_request(self, requests, path=None, overwrite=False, progress=True,
dl_set = False
# Private communication from JSOC say we should not use more than one connection.
if max_conn != self.default_max_conn:
log.info(f"Setting max parallel downloads to 1 for the JSOC client.")
log.info("Setting max parallel downloads to 1 for the JSOC client.")
downloader = Downloader(max_conn=max_conn, progress=progress, overwrite=overwrite, max_splits=max_splits)
urls = []
for request in requests:
Expand Down

0 comments on commit e56d94d

Please sign in to comment.