question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: 'NoneType' object has no attribute 'rstrip'

See original GitHub issue

Getting the following error

AttributeError: 'NoneType' object has no attribute 'rstrip'

Python 3.7.6

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jrschumachercommented, May 14, 2020

@ezbz @needleshaped sorry I was working on a patch. The issue is that there is no check whether or not the URL is defined. I can’t test this due to not knowing enough Python to get an environment setup, but here is a diff of what appears to be needed:

diff --git a/gitlabber/cli.py b/gitlabber/cli.py
index 845b37f..645b6be 100644
--- a/gitlabber/cli.py
+++ b/gitlabber/cli.py
@@ -1,6 +1,7 @@
 
 import os
 import sys
+from urllib.parse import urlparse
 import logging
 import logging.handlers
 import enum
@@ -18,6 +19,17 @@ def main():
         print(VERSION)
         sys.exit(0) 
 
+    if args.token is None:
+        print('Requires a valid token')
+        sys.exit(1)
+
+    try:
+        urlparse(args.url)
+    except ValueError:
+        print('Requires a valid url')
+        sys.exit(1)
+
+
     config_logging(args)
     includes=split(args.include)
     excludes=split(args.exclude)
@@ -84,13 +96,13 @@ def parse_args(argv=None):
         '-t',
         '--token',
         metavar=('token'),
-        default=os.environ.get('GITLAB_TOKEN'),
+        default=os.environ.get('GITLAB_TOKEN', None),
         help='gitlab personal access token https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html')
     parser.add_argument(
         '-u',
         '--url',
         metavar=('url'),
-        default=os.environ.get('GITLAB_URL'),
+        default=os.environ.get('GITLAB_URL', 'https://gitlab.com'),
         help='gitlab url (e.g.: \'http://gitlab.mycompany.com\')')
     parser.add_argument(
         '--verbose',
Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError: 'NoneType' object has no attribute 'strip'
string doesn't return anything, so you're calling the strip() method on something that doesn't exist. However, then you have another problem; ...
Read more >
AttributeError: 'NoneType' object has no attribute 'strip' #70
The error is because the python str method .strip() is trying to operate on a None, rather than the expected string. The only...
Read more >
'nonetype' object has no attribute 'rstrip' - You.com | The AI ...
The error is pretty clear: fh is a file object, which doesn't have a rstrip method. Looks like you want line.rstrip() instead. Open...
Read more >
7920 (AttributeError: 'NoneType' object has no attribute 'rstrip')
Hi. I installed the ContextMenu plugin by building the egg from source. (Python 2.5.4) It installed successfully. But causes error below when I...
Read more >
Error: 'NoneType' object has no attribute 'strip' - Google Groups
When I save the record in database I get this error: Error: 'NoneType' object has no attribute 'strip'. My model is: from django.db...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found