Style fixes.

This commit is contained in:
Florian Bruhin 2015-11-13 22:27:41 +01:00
parent 04c2e45bee
commit 1da7996c3b
12 changed files with 19 additions and 41 deletions

View File

@ -814,12 +814,9 @@ class EventFilter(QObject):
Return:
True if the event should be filtered, False if it's passed through.
"""
if qApp.overrideCursor() is None:
# Mouse cursor shown -> don't filter event
return False
else:
# Mouse cursor hidden -> filter event
return True
# Mouse cursor shown (overrideCursor None) -> don't filter event
# Mouse cursor hidden (overrideCursor not None) -> filter event
return qApp.overrideCursor() is not None
def eventFilter(self, obj, event):
"""Handle an event.

View File

@ -37,7 +37,7 @@ class SettingSectionCompletionModel(base.BaseCompletionModel):
def __init__(self, parent=None):
super().__init__(parent)
cat = self.new_category("Sections")
for name in configdata.DATA.keys():
for name in configdata.DATA:
desc = configdata.SECTION_DESC[name].splitlines()[0].strip()
self.new_item(cat, name, desc)
@ -62,7 +62,7 @@ class SettingOptionCompletionModel(base.BaseCompletionModel):
self._misc_items = {}
self._section = section
objreg.get('config').changed.connect(self.update_misc_column)
for name in sectdata.keys():
for name in sectdata:
try:
desc = sectdata.descriptions[name]
except (KeyError, AttributeError):

View File

@ -70,7 +70,7 @@ def _init_setting_completions():
model = configmodel.SettingOptionCompletionModel(sectname)
_instances[usertypes.Completion.option][sectname] = model
_instances[usertypes.Completion.value][sectname] = {}
for opt in configdata.DATA[sectname].keys():
for opt in configdata.DATA[sectname]:
model = configmodel.SettingValueCompletionModel(sectname, opt)
_instances[usertypes.Completion.value][sectname][opt] = model

View File

@ -77,7 +77,7 @@ class HelpCompletionModel(base.BaseCompletionModel):
"""Fill completion with section->option entries."""
cat = self.new_category("Settings")
for sectname, sectdata in configdata.DATA.items():
for optname in sectdata.keys():
for optname in sectdata:
try:
desc = sectdata.descriptions[optname]
except (KeyError, AttributeError):

View File

@ -368,7 +368,7 @@ class ConfigManager(QObject):
self.sections = configdata.data()
self._interpolation = configparser.ExtendedInterpolation()
self._proxies = {}
for sectname in self.sections.keys():
for sectname in self.sections:
self._proxies[sectname] = SectionProxy(self, sectname)
self._fname = fname
if configdir is None:

View File

@ -273,10 +273,8 @@ class KeyConfigParser(QObject):
return True
if keychain in bindings:
return False
elif command in bindings.values():
return False
else:
return True
return command not in bindings.values()
def _read(self, relaxed=False):
"""Read the config file from disk and parse it.

View File

@ -371,10 +371,8 @@ class QtWarningFilter(logging.Filter):
def filter(self, record):
"""Determine if the specified record is to be logged."""
if record.msg.strip().startswith(self._pattern):
return False # filter
else:
return True # log
do_log = not record.msg.strip().startswith(self._pattern)
return do_log
class LogFilter(logging.Filter):

View File

@ -122,10 +122,7 @@ def _is_url_naive(urlstr):
if not QHostAddress(urlstr).isNull():
return False
if '.' in url.host():
return True
else:
return False
return '.' in url.host()
def _is_url_dns(urlstr):
@ -254,10 +251,7 @@ def is_url(urlstr):
# no autosearch, so everything is a URL unless it has an explicit
# search engine.
engine, _term = _parse_search_term(urlstr)
if engine is None:
return True
else:
return False
return engine is None
if not qurl_userinput.isValid():
# This will also catch URLs containing spaces.

View File

@ -93,10 +93,8 @@ def is_qutebrowser_dump(parsed):
return True
else:
return '-m qutebrowser' in cmdline
elif basename == 'qutebrowser':
return True
else:
return False
return basename == 'qutebrowser'
def dump_infos_gdb(parsed):

View File

@ -110,11 +110,7 @@ def filter_func(item):
True if the missing function should be filtered/ignored, False
otherwise.
"""
if re.match(r'[a-z]+[A-Z][a-zA-Z]+', str(item)):
# probably a virtual Qt method
return True
else:
return False
return bool(re.match(r'[a-z]+[A-Z][a-zA-Z]+', str(item)))
def report(items):

View File

@ -121,11 +121,8 @@ def pytest_collection_modifyitems(items):
def pytest_ignore_collect(path):
"""Ignore BDD tests during collection if frozen."""
rel_path = path.relto(os.path.dirname(__file__))
if (rel_path == os.path.join('integration', 'features') and
hasattr(sys, 'frozen')):
return True
else:
return False
return (rel_path == os.path.join('integration', 'features') and
hasattr(sys, 'frozen'))
@pytest.fixture(scope='session')

View File

@ -147,7 +147,7 @@ def test_cache_nonexistent_metadata_file(config_stub, tmpdir):
disk_cache = cache.DiskCache(str(tmpdir))
cache_file = disk_cache.fileMetaData("nosuchfile")
assert cache_file.isValid() == False
assert cache_file.isValid()
def test_cache_deactivated_metadata_file(config_stub, tmpdir):
@ -207,7 +207,7 @@ def test_cache_deactivated_remove_data(config_stub, tmpdir):
disk_cache = cache.DiskCache(str(tmpdir))
url = QUrl('http://www.example.com/')
assert disk_cache.remove(url) == False
assert disk_cache.remove(url)
def test_cache_insert_data(config_stub, tmpdir):