Remove unneeded # NOQA comments

It appears that something has changed and it no longer complains about double
declaration in else or except blocks.
This commit is contained in:
ZyX 2014-08-31 23:01:40 +04:00
parent 06211cbe63
commit 8d00ba781c
18 changed files with 39 additions and 39 deletions

View File

@ -76,14 +76,14 @@ else:
_vim_exists = vim_get_func('exists', rettype=int)
def vim_getvar(varname): # NOQA
def vim_getvar(varname):
varname = 'g:' + varname
if _vim_exists(varname):
return vim.eval(varname)
else:
raise KeyError(varname)
def bufvar_exists(buffer, varname): # NOQA
def bufvar_exists(buffer, varname):
if not buffer or buffer.number == vim.current.buffer.number:
return int(vim.eval('exists("b:{0}")'.format(varname)))
else:
@ -91,7 +91,7 @@ else:
'has_key(getbufvar({0}, ""), {1})'.format(buffer.number, varname)
))
def vim_getwinvar(segment_info, varname): # NOQA
def vim_getwinvar(segment_info, varname):
result = vim.eval('getwinvar({0}, "{1}")'.format(segment_info['winnr'], varname))
if result == '':
if not int(vim.eval('has_key(getwinvar({0}, ""), "{1}")'.format(segment_info['winnr'], varname))):
@ -125,13 +125,13 @@ if hasattr(vim, 'options'):
def vim_setoption(option, value):
vim.options[str(option)] = value
else:
def vim_getbufoption(info, option): # NOQA
def vim_getbufoption(info, option):
return getbufvar(info['bufnr'], '&' + option)
def vim_getoption(option): # NOQA
def vim_getoption(option):
return vim.eval('&g:' + option)
def vim_setoption(option, value): # NOQA
def vim_setoption(option, value):
vim.command('let &g:{option} = {value}'.format(
option=option, value=json.encode(value)))
@ -208,10 +208,10 @@ else:
def _last_tab_nr():
return int(vim.eval('tabpagenr("$")'))
def current_tabpage(): # NOQA
def current_tabpage():
return Tabpage(int(vim.eval('tabpagenr()')))
def list_tabpages(): # NOQA
def list_tabpages():
return [Tabpage(nr) for nr in range(1, _last_tab_nr() + 1)]
class TabBufSegmentInfo(dict):
@ -261,7 +261,7 @@ if sys.version_info < (3,):
else:
vim_bufname = vim_get_func('bufname')
def buffer_name(buf): # NOQA
def buffer_name(buf):
try:
name = buf.name
except UnicodeDecodeError:

View File

@ -9,12 +9,12 @@ try:
# >={kernel}-sources-2.6.28
from time import CLOCK_MONOTONIC_RAW as CLOCK_ID
except ImportError:
from time import CLOCK_MONOTONIC as CLOCK_ID # NOQA
from time import CLOCK_MONOTONIC as CLOCK_ID
monotonic = lambda: clock_gettime(CLOCK_ID)
except ImportError:
# >=python-3.3
from time import monotonic # NOQA
from time import monotonic
except ImportError:
import ctypes
import sys
@ -25,7 +25,7 @@ except ImportError:
GetTickCount64 = ctypes.windll.kernel32.GetTickCount64
GetTickCount64.restype = ctypes.c_ulonglong
def monotonic(): # NOQA
def monotonic():
return GetTickCount64() / 1000
elif sys.platform == 'darwin':
@ -61,7 +61,7 @@ except ImportError:
timebase = mach_timebase_info()
factor = timebase[0] / timebase[1] * 1e-9
def monotonic(): # NOQA
def monotonic():
return mach_absolute_time() * factor
else:
# linux only (no librt on OS X)
@ -90,7 +90,7 @@ except ImportError:
else:
raise OSError
def monotonic(): # NOQA
def monotonic():
if clock_gettime(CLOCK_MONOTONIC, ctypes.pointer(tspec)) != 0:
errno_ = ctypes.get_errno()
raise OSError(errno_, os.strerror(errno_))

View File

@ -68,7 +68,7 @@ try:
except ImportError:
# shutil.which was added in python-3.3. Here is what was added:
# Lib/shutil.py, commit 5abe28a9c8fe701ba19b1db5190863384e96c798
def which(cmd, mode=os.F_OK | os.X_OK, path=None): # NOQA
def which(cmd, mode=os.F_OK | os.X_OK, path=None):
"""Given a command, mode, and a PATH string, return the path which
conforms to the given mode on the PATH, or None if there is no such
file.

View File

@ -7,7 +7,7 @@ from locale import getpreferredencoding
try:
from __builtin__ import unicode
except ImportError:
unicode = str # NOQA
unicode = str
try:

View File

@ -2,8 +2,8 @@
from __future__ import (unicode_literals, division, absolute_import, print_function)
try:
from urllib.error import HTTPError
from urllib.request import urlopen
from urllib.error import HTTPError # NOQA
from urllib.request import urlopen # NOQA
from urllib.parse import urlencode as urllib_urlencode # NOQA
except ImportError:
from urllib2 import urlopen, HTTPError # NOQA

View File

@ -7,7 +7,7 @@ from powerline.bindings.vim import (current_tabpage, list_tabpages, vim_getbufop
try:
import vim
except ImportError:
vim = {} # NOQA
vim = {}
def tabpage_updated_segment_info(segment_info, tabpage, mode):

View File

@ -6,7 +6,7 @@ import os
try:
import vim
except ImportError:
vim = object() # NOQA
vim = object()
else:
vim.command('''
function! Powerline_plugin_ctrlp_main(...)

View File

@ -76,7 +76,7 @@ class VimRenderer(Renderer):
# renderer
return vim.strwidth(string.encode('utf-8'))
else:
@staticmethod # NOQA
@staticmethod
def strwidth(string):
return vim.strwidth(string)

View File

@ -26,7 +26,7 @@ class Segment(object):
def argspecobjs(self):
yield '__call__', self.__call__
else:
def argspecobjs(self): # NOQA
def argspecobjs(self):
yield '__call__', self
argspecobjs.__doc__ = (

View File

@ -675,23 +675,23 @@ try:
'highlight_group': ['cpu_load_percent_gradient', 'cpu_load_percent'],
}]
except ImportError:
def _get_bytes(interface): # NOQA
def _get_bytes(interface):
with open('/sys/class/net/{interface}/statistics/rx_bytes'.format(interface=interface), 'rb') as file_obj:
rx = int(file_obj.read())
with open('/sys/class/net/{interface}/statistics/tx_bytes'.format(interface=interface), 'rb') as file_obj:
tx = int(file_obj.read())
return (rx, tx)
def _get_interfaces(): # NOQA
def _get_interfaces():
for interface in os.listdir('/sys/class/net'):
x = _get_bytes(interface)
if x is not None:
yield interface, x[0], x[1]
def _get_user(segment_info): # NOQA
def _get_user(segment_info):
return segment_info['environ'].get('USER', None)
class CPULoadPercentSegment(ThreadedSegment): # NOQA
class CPULoadPercentSegment(ThreadedSegment):
interval = 1
@staticmethod
@ -763,12 +763,12 @@ if os.path.exists('/proc/uptime'):
elif 'psutil' in globals():
from time import time
def _get_uptime(): # NOQA
def _get_uptime():
# psutil.BOOT_TIME is not subject to clock adjustments, but time() is.
# Thus it is a fallback to /proc/uptime reading and not the reverse.
return int(time() - psutil.BOOT_TIME)
else:
def _get_uptime(): # NOQA
def _get_uptime():
raise NotImplementedError
@ -1198,14 +1198,14 @@ class NowPlayingSegment(Segment):
}
try:
__import__('dbus') # NOQA
__import__('dbus')
except ImportError:
if sys.platform.startswith('darwin'):
player_spotify = player_spotify_apple_script
else:
player_spotify = player_spotify_dbus # NOQA
player_spotify = player_spotify_dbus
else:
player_spotify = player_spotify_dbus # NOQA
player_spotify = player_spotify_dbus
def player_rhythmbox(self, pl):
now_playing = run_cmd(pl, ['rhythmbox-client', '--no-start', '--no-present', '--print-playing-format', '%at\n%aa\n%tt\n%te\n%td'])

View File

@ -9,7 +9,7 @@ from collections import defaultdict
try:
import vim
except ImportError:
vim = {} # NOQA
vim = {}
from powerline.bindings.vim import (vim_get_func, getbufvar, vim_getbufoption,
buffer_name, vim_getwinvar,

View File

@ -4,7 +4,7 @@ from __future__ import (unicode_literals, division, absolute_import, print_funct
try:
import vim
except ImportError:
vim = object() # NOQA
vim = object()
from powerline.bindings.vim import getbufvar
from powerline.segments.vim import window_cached

View File

@ -4,7 +4,7 @@ from __future__ import (unicode_literals, division, absolute_import, print_funct
try:
import vim
except ImportError:
vim = object() # NOQA
vim = object()
from powerline.bindings.vim import bufvar_exists
from powerline.segments.vim import window_cached

View File

@ -4,7 +4,7 @@ from __future__ import (unicode_literals, division, absolute_import, print_funct
try:
import vim
except ImportError:
vim = object() # NOQA
vim = object()
from powerline.segments.vim import window_cached

View File

@ -4,7 +4,7 @@ from __future__ import (unicode_literals, division, absolute_import, print_funct
try:
import vim
except ImportError:
vim = object() # NOQA
vim = object()
from powerline.segments.vim import window_cached

View File

@ -214,7 +214,7 @@ class VimPowerline(Powerline):
_vim_getwinvar = staticmethod(vim_get_func('getwinvar'))
_vim_setwinvar = staticmethod(vim_get_func('setwinvar'))
def win_idx(self, window_id): # NOQA
def win_idx(self, window_id):
r = None
for winnr, window in zip(count(1), vim.windows):
curwindow_id = self._vim_getwinvar(winnr, 'powerline_window_id')

View File

@ -13,7 +13,7 @@ except ImportError:
import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(os.path.realpath(__file__)))))
import powerline.bindings.config as config # NOQA
import powerline.bindings.config as config
TMUX_ACTIONS = {

View File

@ -14,7 +14,7 @@ try:
from powerline.shell import ShellPowerline, get_argparser, finish_args, write_output
except ImportError:
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(os.path.realpath(__file__)))))
from powerline.shell import ShellPowerline, get_argparser, finish_args, write_output # NOQA
from powerline.shell import ShellPowerline, get_argparser, finish_args, write_output
if sys.version_info < (3,):