Skip to content

Commit

Permalink
Fixes some pylint issues.
Browse files Browse the repository at this point in the history
This doesn't fix all complaints by pylint, but significantly
reduces their number.  Ditto for pep8 complaints.

Also makes a couple of related cosmetic edits.

TESTED:
Ran "scons build-all check" with no errors.
Both "pylint" and "pep8" targets report fewer issues.
  • Loading branch information
fhgwright committed Jul 14, 2017
1 parent 81e3562 commit bda3f97
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 39 deletions.
3 changes: 2 additions & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -1766,7 +1766,8 @@ if len(python_progs) > 0:
'''C0302,C0322,C0324,C0323,C0321,C0330,R0201,R0801,R0902,R0903,'''
'''R0904,R0911,R0912,R0913,R0914,R0915,W0110,W0201,W0121,W0123,'''
'''W0231,W0232,W0234,W0401,W0403,W0141,W0142,W0603,W0614,W0640,'''
'''W0621,W1504,E0602,E0611,E1101,E1102,E1103,F0401 gps/*.py *.py '''
'''W0621,W1504,E0602,E0611,E1101,E1102,E1103,F0401,I0011 '''
'''gps/*.py *.py '''
+ " ".join(python_progs)])

# Additional Python readability style checks
Expand Down
3 changes: 2 additions & 1 deletion gegps
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
from __future__ import absolute_import, print_function, division

import getopt
import gps
import os
import sys

import gps

KML_OPEN_IN_GE = '''\
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
Expand Down
6 changes: 3 additions & 3 deletions gps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
# Preserve this property!
from __future__ import absolute_import # Ensure Python2 behaves like Python 3

api_major_version = 5 # bumped on incompatible changes
api_minor_version = 0 # bumped on compatible changes

from .gps import *
from .misc import *

api_major_version = 5 # bumped on incompatible changes
api_minor_version = 0 # bumped on compatible changes

# The 'client' module exposes some C utility functions for Python clients.
# The 'packet' module exposes the packet getter via a Python interface.
2 changes: 1 addition & 1 deletion gps/fake.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
import select
import signal
import socket
import stat
import subprocess
import sys
import termios # fcntl, array, struct
Expand All @@ -87,7 +88,6 @@
import gps
from gps import polybytes
from . import packet as sniffer
import stat

# The magic number below has to be derived from observation. If
# it's too high you'll slow the tests down a lot. If it's too low
Expand Down
3 changes: 1 addition & 2 deletions gps/gps.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from __future__ import absolute_import, print_function, division

from .client import *
from .misc import isotime

NaN = float('nan')

Expand Down Expand Up @@ -213,7 +212,7 @@ def default(k, dflt, vbit=0):
self.driver_mode = default("native", 0)
self.mincycle = default("mincycle", NaN)
self.serialmode = default("serialmode", "8N1")
# FIXME: decode DEVICSES
# FIXME: decode DEVICES
# FIXME: decode PPS
elif self.data.get("class") == "TPV":
self.device = default("device", "missing")
Expand Down
4 changes: 2 additions & 2 deletions gps/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def EarthDistance(c1, c2):
f = 1 / 298.257223563
b = 6356752.314245 # meters; b = (1 - f)a

MILES_PER_KILOMETER = 0.621371
# MILES_PER_KILOMETER = 1000.0 / (.3048 * 5280.0)

MAX_ITERATIONS = 200
CONVERGENCE_THRESHOLD = 1e-12 # .000,000,000,001
Expand All @@ -171,7 +171,7 @@ def EarthDistance(c1, c2):
sinU2 = math.sin(U2)
cosU2 = math.cos(U2)

for iteration in range(MAX_ITERATIONS):
for _ in range(MAX_ITERATIONS):
sinLambda = math.sin(Lambda)
cosLambda = math.cos(Lambda)
sinSigma = math.sqrt((cosU2 * sinLambda) ** 2 +
Expand Down
6 changes: 4 additions & 2 deletions gpscat
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@
# Preserve this property!
from __future__ import absolute_import, print_function, division

import curses.ascii
import getopt
import gps.packet as sniffer
import os
import select
import socket
import sys
import termios

import curses.ascii

import gps.packet as sniffer

# The spec says 82, but some receivers (TN-200, GSW 2.3.2) output 86 characters
# the Skyrtaq S2525F8 emits 100 chars
NMEA_MAX = 102
Expand Down
5 changes: 3 additions & 2 deletions gpsfake
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@
from __future__ import absolute_import, print_function, division

import getopt
import gps
import gps.fake as gpsfake # The "as" pacifies pychecker
import os
import platform
import pty
import socket
import sys
import time

import gps
import gps.fake as gpsfake # The "as" pacifies pychecker

try:
my_input = raw_input
except NameError:
Expand Down
3 changes: 2 additions & 1 deletion gpsprof
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ from __future__ import absolute_import, print_function, division

import copy
import getopt
import gps
import math
import os
import signal
import socket
import sys
import time

import gps


class Baton(object):
"Ship progress indication to stderr."
Expand Down
5 changes: 3 additions & 2 deletions gpssim.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
This is proof-of-concept code, not production ready; some functions are stubs.
"""
import gps
import gpslib
import math
import random
import sys
import time

import gps
import gpslib

# First, the mathematics. We simulate a moving viewpoint on the Earth
# and a satellite with specified orbital elements in the sky.

Expand Down
1 change: 1 addition & 0 deletions test_maidenhead.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from __future__ import absolute_import, print_function, division

import sys

import gps.clienthelpers

errors = 0
Expand Down
1 change: 1 addition & 0 deletions test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from __future__ import absolute_import, print_function, division

import sys

import gps.misc

errors = 0
Expand Down
1 change: 1 addition & 0 deletions valgrind-audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from __future__ import absolute_import, print_function, division

import sys

import gps.fake

debuglevel = 1
Expand Down
33 changes: 18 additions & 15 deletions xgps
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,36 @@ usage: xgps [-D level] [-hV?] [-l degmfmt] [-u units] [-r rotation]
[server[:port[:device]]]
'''

# This file is Copyright (c) 2010 by the GPSD project
# BSD terms apply: see the file COPYING in the distribution root for details.
#
# This code runs compatibly under Python 2 and 3.x for x >= 2.
# Preserve this property!
from __future__ import absolute_import, print_function, division

gui_about = '''\
This is xgps, a test client for the gpsd daemon.
By Eric S. Raymond for the GPSD project, December 2009
'''
#
# This file is Copyright (c) 2010 by the GPSD project
# BSD terms apply: see the file COPYING in the distribution root for details.

import math
import socket
import sys
import time

from gi.repository import GObject
import gps
import gps.clienthelpers

import cairo

# Gtk3 imports. Gtk3 requires the require_version(), which then causes
# pylint to complain about the subsequent "non-top" imports.
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import Gdk
import cairo
from gi.repository import GObject # pylint: disable=wrong-import-position
from gi.repository import Gtk # pylint: disable=wrong-import-position
from gi.repository import Gdk # pylint: disable=wrong-import-position

import gps
import gps.clienthelpers
gui_about = '''\
This is xgps, a test client for the gpsd daemon.
By Eric S. Raymond for the GPSD project, December 2009
'''

# Use our own MAXCHANNELS value, due to the tradeoff between max sats and
# the window size. Ideally, this should be dynamic.
Expand Down
19 changes: 12 additions & 7 deletions xgpsspeed
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,25 @@
# Preserve this property!
from __future__ import absolute_import, print_function, division

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import Gdk
import cairo
from gi.repository import GObject
import gps
from math import pi
from math import cos
from math import sin
from math import sqrt
from math import radians
from socket import error as SocketError

import gps

import cairo

# Gtk3 imports. Gtk3 requires the require_version(), which then causes
# pylint to complain about the subsequent "non-top" imports.
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk # pylint: disable=wrong-import-position
from gi.repository import Gdk # pylint: disable=wrong-import-position
from gi.repository import GObject # pylint: disable=wrong-import-position


class Speedometer(Gtk.DrawingArea):
def __init__(self, speed_unit=None):
Expand Down

0 comments on commit bda3f97

Please sign in to comment.