[tor-commits] [nyx/master] Fix is_available() ternary

atagar at torproject.org atagar at torproject.org
Tue Nov 19 01:19:16 UTC 2019


commit 2fef5f6b70b987a839e4a907e9858c37a56f5100
Author: Damian Johnson <atagar at torproject.org>
Date:   Mon Nov 18 16:30:50 2019 -0800

    Fix is_available() ternary
    
    This was simply returning the result of shutil. The proper ternary is...
    
      return True if shutil.which(command) else False
    
    That said, this really doesn't matter. Usage within conditionals implicitly
    converts this to a boolean anyway.
---
 nyx/__init__.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/nyx/__init__.py b/nyx/__init__.py
index 0418567..0efdbed 100644
--- a/nyx/__init__.py
+++ b/nyx/__init__.py
@@ -51,8 +51,10 @@ import threading
 import time
 import shutil
 
+
 def is_available(command):
-   return shutil.which(command) if True else False
+   return bool(shutil.which(command))
+
 
 class PkgManagers:
   ARCHLINUX = 'pacman'
@@ -93,7 +95,7 @@ except ImportError as exc:
     else:
       pkg_manager_not_found = True
       pkg_install_procedure = ', you can find it at https://stem.torproject.org/download.html'
-    
+
     require_message = 'nyx requires python-stem'
     if pkg_manager_not_found:
       final_message = require_message + pkg_install_procedure





More information about the tor-commits mailing list