Repository: falconry/falcon

Issue:
pep8 test failing due F405 and F401
Currently, pull requests are not passing in Travis during 'tox -e pep8' due to two main issues:
1) F405: In falcon/requests.py (line 33), the following import is causing an issue:

``` python
from falcon.errors import *  # NOQA
```

Surprisingly, this is the only time an import is done in an file that is not **init**.py

2) F401: In line 4 of falcon/util/**init**.py (dunder init.py):

``` python
from falcon.util.time import *
```

Is giving an error because of missing '# NOQA' as the end of the line

Some pull requests affected by this isse:
1) #829
2) #809 
3) #815 



Discussion:

Resolving patch:
diff --git a/falcon/request.py b/falcon/request.py
--- a/falcon/request.py
+++ b/falcon/request.py
@@ -30,8 +30,9 @@
 import six
 from six.moves import http_cookies
 
-from falcon.errors import *  # NOQA
-from falcon import request_helpers as helpers, util
+from falcon import errors
+from falcon import request_helpers as helpers
+from falcon import util
 from falcon.util.uri import parse_host, parse_query_string, unquote_string
 
 # NOTE(tbug): In some cases, http_cookies is not a module
@@ -379,11 +380,11 @@ def content_length(self):
             value_as_int = int(value)
         except ValueError:
             msg = 'The value of the header must be a number.'
-            raise HTTPInvalidHeader(msg, 'Content-Length')
+            raise errors.HTTPInvalidHeader(msg, 'Content-Length')
 
         if value_as_int < 0:
             msg = 'The value of the header must be a positive number.'
-            raise HTTPInvalidHeader(msg, 'Content-Length')
+            raise errors.HTTPInvalidHeader(msg, 'Content-Length')
 
         return value_as_int
 
@@ -407,13 +408,13 @@ def range(self):
                 unit, sep, req_range = value.partition('=')
             else:
                 msg = "The value must be prefixed with a range unit, e.g. 'bytes='"
-                raise HTTPInvalidHeader(msg, 'Range')
+                raise errors.HTTPInvalidHeader(msg, 'Range')
         except KeyError:
             return None
 
         if ',' in req_range:
             msg = 'The value must be a continuous range.'
-            raise HTTPInvalidHeader(msg, 'Range')
+            raise errors.HTTPInvalidHeader(msg, 'Range')
 
         try:
             first, sep, last = req_range.partition('-')
@@ -427,14 +428,14 @@ def range(self):
                 return (-int(last), -1)
             else:
                 msg = 'The range offsets are missing.'
-                raise HTTPInvalidHeader(msg, 'Range')
+                raise errors.HTTPInvalidHeader(msg, 'Range')
 
         except ValueError:
             href = 'http://goo.gl/zZ6Ey'
             href_text = 'HTTP/1.1 Range Requests'
             msg = ('It must be a range formatted according to RFC 7233.')
-            raise HTTPInvalidHeader(msg, 'Range', href=href,
-                                    href_text=href_text)
+            raise errors.HTTPInvalidHeader(msg, 'Range', href=href,
+                                           href_text=href_text)
 
     @property
     def range_unit(self):
@@ -446,7 +447,7 @@ def range_unit(self):
                 return unit
             else:
                 msg = "The value must be prefixed with a range unit, e.g. 'bytes='"
-                raise HTTPInvalidHeader(msg, 'Range')
+                raise errors.HTTPInvalidHeader(msg, 'Range')
         except KeyError:
             return None
 
@@ -695,7 +696,7 @@ def get_header(self, name, required=False):
             if not required:
                 return None
 
-            raise HTTPMissingHeader(name)
+            raise errors.HTTPMissingHeader(name)
 
     def get_header_as_datetime(self, header, required=False, obs_date=False):
         """Return an HTTP header with HTTP-Date values as a datetime.
@@ -728,7 +729,7 @@ def get_header_as_datetime(self, header, required=False, obs_date=False):
         except ValueError:
             msg = ('It must be formatted according to RFC 7231, '
                    'Section 7.1.1.1')
-            raise HTTPInvalidHeader(msg, header)
+            raise errors.HTTPInvalidHeader(msg, header)
 
     def get_param(self, name, required=False, store=None, default=None):
         """Return the raw value of a query string parameter as a string.
@@ -789,7 +790,7 @@ def get_param(self, name, required=False, store=None, default=None):
         if not required:
             return default
 
-        raise HTTPMissingParam(name)
+        raise errors.HTTPMissingParam(name)
 
     def get_param_as_int(self, name,
                          required=False, min=None, max=None, store=None):
@@ -837,15 +838,15 @@ def get_param_as_int(self, name,
                 val = int(val)
             except ValueError:
                 msg = 'The value must be an integer.'
-                raise HTTPInvalidParam(msg, name)
+                raise errors.HTTPInvalidParam(msg, name)
 
             if min is not None and val < min:
                 msg = 'The value must be at least ' + str(min)
-                raise HTTPInvalidParam(msg, name)
+                raise errors.HTTPInvalidParam(msg, name)
 
             if max is not None and max < val:
                 msg = 'The value may not exceed ' + str(max)
-                raise HTTPInvalidParam(msg, name)
+                raise errors.HTTPInvalidParam(msg, name)
 
             if store is not None:
                 store[name] = val
@@ -855,7 +856,7 @@ def get_param_as_int(self, name,
         if not required:
             return None
 
-        raise HTTPMissingParam(name)
+        raise errors.HTTPMissingParam(name)
 
     def get_param_as_bool(self, name, required=False, store=None,
                           blank_as_true=False):
@@ -909,7 +910,7 @@ def get_param_as_bool(self, name, required=False, store=None,
                 val = True
             else:
                 msg = 'The value of the parameter must be "true" or "false".'
-                raise HTTPInvalidParam(msg, name)
+                raise errors.HTTPInvalidParam(msg, name)
 
             if store is not None:
                 store[name] = val
@@ -919,7 +920,7 @@ def get_param_as_bool(self, name, required=False, store=None,
         if not required:
             return None
 
-        raise HTTPMissingParam(name)
+        raise errors.HTTPMissingParam(name)
 
     def get_param_as_list(self, name,
                           transform=None, required=False, store=None):
@@ -981,7 +982,7 @@ def get_param_as_list(self, name,
 
                 except ValueError:
                     msg = 'The value is not formatted correctly.'
-                    raise HTTPInvalidParam(msg, name)
+                    raise errors.HTTPInvalidParam(msg, name)
 
             if store is not None:
                 store[name] = items
@@ -991,7 +992,7 @@ def get_param_as_list(self, name,
         if not required:
             return None
 
-        raise HTTPMissingParam(name)
+        raise errors.HTTPMissingParam(name)
 
     def get_param_as_date(self, name, format_string='%Y-%m-%d',
                           required=False, store=None):
@@ -1030,7 +1031,7 @@ def get_param_as_date(self, name, format_string='%Y-%m-%d',
             date = strptime(param_value, format_string).date()
         except ValueError:
             msg = 'The date value does not match the required format'
-            raise HTTPInvalidParam(msg, name)
+            raise errors.HTTPInvalidParam(msg, name)
 
         if store is not None:
             store[name] = date
@@ -1078,7 +1079,7 @@ def _wrap_stream(self):
 
         # NOTE(kgriffs): This branch is indeed covered in test_wsgi.py
         # even though coverage isn't able to detect it.
-        except HTTPInvalidHeader:  # pragma: no cover
+        except errors.HTTPInvalidHeader:  # pragma: no cover
             # NOTE(kgriffs): The content-length header was specified,
             # but it had an invalid value. Assume no content.
             content_length = 0
diff --git a/falcon/util/__init__.py b/falcon/util/__init__.py
--- a/falcon/util/__init__.py
+++ b/falcon/util/__init__.py
@@ -1,6 +1,6 @@
 # Hoist misc. utils
 from falcon.util import structures
 from falcon.util.misc import *  # NOQA
-from falcon.util.time import *
+from falcon.util.time import *  # NOQA
 
 CaseInsensitiveDict = structures.CaseInsensitiveDict


Test patch: