Skip to content

Commit e675351

Browse files
committed
PEP E501 (file length) fix applied
1 parent 2d4ad01 commit e675351

51 files changed

Lines changed: 185 additions & 172 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apprise/attachment/http.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2626
# POSSIBILITY OF SUCH DAMAGE.
2727

28+
import contextlib
2829
import os
2930
import re
3031
from tempfile import NamedTemporaryFile
@@ -286,13 +287,10 @@ def invalidate(self):
286287
self.logger.trace("Attachment cleanup of %s", self._temp_file.name)
287288
self._temp_file.close()
288289

289-
try:
290+
with contextlib.suppress(OSError):
290291
# Ensure our file is removed (if it exists)
291292
os.unlink(self._temp_file.name)
292293

293-
except OSError:
294-
pass
295-
296294
# Reset our temporary file to prevent from entering
297295
# this block again
298296
self._temp_file = None

apprise/logger.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2626
# POSSIBILITY OF SUCH DAMAGE.
2727

28+
import contextlib
2829
from io import StringIO
2930
import logging
3031
import os
@@ -186,12 +187,8 @@ def __exit__(self, exc_type, exc_value, tb):
186187
self.__buffer_ptr.close()
187188
self.__handler.close()
188189
if self.__delete:
189-
try:
190+
with contextlib.suppress(OSError):
190191
# Always remove file afterwards
191192
os.unlink(self.__path)
192193

193-
except OSError:
194-
# It's okay if the file does not exist
195-
pass
196-
197194
return exc_type is None

apprise/persistent_store.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
# THE SOFTWARE.
2424
import base64
2525
import binascii
26+
import contextlib
2627
from datetime import datetime, timedelta, timezone
2728
import glob
2829
import gzip
@@ -52,13 +53,9 @@ def _ntf_tidy(ntf):
5253
"""Reusable NamedTemporaryFile cleanup."""
5354
if ntf:
5455
# Cleanup
55-
try:
56+
with contextlib.suppress(OSError):
5657
ntf.close()
5758

58-
except OSError:
59-
# Already closed
60-
pass
61-
6259
try:
6360
os.unlink(ntf.name)
6461
logger.trace("Persistent temporary file removed: %s", ntf.name)

apprise/plugins/aprs.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
# http://www.aprs.org/doc/APRS101.PDF
6767
#
6868

69+
import contextlib
6970
from itertools import chain
7071
import re
7172
import socket
@@ -321,13 +322,8 @@ def __init__(self, targets=None, locale=None, delay=None, **kwargs):
321322
def socket_close(self):
322323
"""Closes the socket connection whereas present."""
323324
if self.sock:
324-
try:
325+
with contextlib.suppress(Exception):
325326
self.sock.close()
326-
327-
except Exception:
328-
# No worries if socket exception thrown on close()
329-
pass
330-
331327
self.sock = None
332328

333329
def socket_open(self):

apprise/plugins/base.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,11 @@ class NotifyBase(URLBase):
187187
"default": overflow_mode,
188188
# look up default using the following parent class value at
189189
# runtime. The variable name identified here (in this case
190-
# overflow_mode) is checked and it's result is placed over-top of
191-
# the 'default'. This is done because once a parent class inherits
192-
# this one, the overflow_mode already set as a default 'could' be
193-
# potentially over-ridden and changed to a different value.
190+
# overflow_mode) is checked and it's result is placed over-top
191+
# of the 'default'. This is done because once a parent class
192+
# inherits this one, the overflow_mode already set as a default
193+
# 'could' be potentially over-ridden and changed to a different
194+
# value.
194195
"_lookup_default": "overflow_mode",
195196
},
196197
"format": {

apprise/plugins/d7networks.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,11 @@ class NotifyD7Networks(NotifyBase):
133133
"alias_of": "targets",
134134
},
135135
"source": {
136-
# Originating address,In cases where the rewriting of the sender's
137-
# address is supported or permitted by the SMS-C. This is used to
138-
# transmit the message, this number is transmitted as the
139-
# originating address and is completely optional.
136+
# Originating address,In cases where the rewriting of the
137+
# sender's address is supported or permitted by the SMS-C.
138+
# This is used to transmit the message, this number is
139+
# transmitted as the originating address and is completely
140+
# optional.
140141
"name": _("Originating Address"),
141142
"type": "string",
142143
"map_to": "source",

apprise/plugins/gnome.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ class NotifyGnome(NotifyBase):
144144
"default": GnomeUrgency.NORMAL,
145145
},
146146
"priority": {
147-
# Apprise uses 'priority' everywhere; it's just a nice consistent
148-
# feel to be able to use it here as well. Just map the
149-
# value back to 'priority'
147+
# Apprise uses 'priority' everywhere; it's just a nice
148+
# consistent feel to be able to use it here as well. Just map
149+
# the value back to 'priority'
150150
"alias_of": "urgency",
151151
},
152152
"image": {

apprise/plugins/gotify.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
# Gotify Docker configuration: https://hub.docker.com/r/gotify/server
2929
# Example: https://github.com/gotify/server/blob/\
30-
# f2c2688f0b5e6a816bbcec768ca1c0de5af76b88/ADD_MESSAGE_EXAMPLES.md#python
30+
# f2c2688f0b5e6a816bbcec768ca1c0de5af76b88/ADD_MESSAGE_EXAMPLES.md#python
3131
# API: https://gotify.net/docs/swagger-docs
3232

3333
from json import dumps

apprise/plugins/lametric.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
# - https://developer.lametric.com/icons
8787

8888

89+
import contextlib
8990
from json import dumps
9091
import re
9192

@@ -1103,13 +1104,9 @@ def parse_url(url):
11031104
)
11041105

11051106
# Set cycles
1106-
try:
1107+
with contextlib.suppress(TypeError, ValueError):
11071108
results["cycles"] = abs(int(results["qsd"].get("cycles")))
11081109

1109-
except (TypeError, ValueError):
1110-
# Not a valid integer; ignore entry
1111-
pass
1112-
11131110
return results
11141111

11151112
@staticmethod

apprise/plugins/lark.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ def url(self, privacy=False, *args, **kwargs):
9696
"""Returns the URL built dynamically based on specified arguments."""
9797
params = self.url_parameters(privacy=privacy, *args, **kwargs)
9898
return (
99-
f"{self.secure_protocol}://{self.pprint(self.token, privacy, mode=PrivacyMode.Secret)}/?{NotifyLark.urlencode(params)}"
99+
f"{self.secure_protocol}://"
100+
f"{self.pprint(self.token, privacy, mode=PrivacyMode.Secret)}/"
101+
f"?{NotifyLark.urlencode(params)}"
100102
)
101103

102104
def send(self, body, title="", notify_type=NotifyType.INFO, **kwargs):

0 commit comments

Comments
 (0)