Repository: Flexget/Flexget

Issue:
Warnings in Python 3.8
Deprecation warning due to invalid escape sequences. Using raw strings or escaping them again helps in resolving this. Check https://github.com/asottile/pyupgrade/ for automatic fix of this.

Syntax warnings are caused due to comparison of literals using is. 

### Steps to reproduce:

```
find . -iname '*.py' | grep -Ev 'rdf4|tool|doc' | xargs -P4 -I{} python3.8 -Wall -m py_compile {}
./update-changelog.py:49: DeprecationWarning: invalid escape sequence \d
  '#(\d{3,4})', r'[#\1](https://github.com/Flexget/Flexget/issues/\1)', item
./update-changelog.py:58: DeprecationWarning: invalid escape sequence \[
  for cat_match in re.finditer('\[(\w+)\]', line):
./update-changelog.py:109: DeprecationWarning: invalid escape sequence \s
  latestref = re.match('<!---\s*([\d\w]+)', start_comment).group(1)
./update-changelog.py:110: DeprecationWarning: invalid escape sequence \s
  oldestref = re.match('<!---\s*([\d\w]+)', end_comment).group(1)
./flexget/plugins/internal/api_rottentomatoes.py:35: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if ver is 0:
./flexget/plugins/internal/api_rottentomatoes.py:55: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if ver is 1:
./flexget/tests/api_tests/test_etag.py:37: SyntaxWarning: "is" with a literal. Did you mean "=="?
  assert data is ''
```

### Additional information:

- FlexGet version: master branch
- Python version: 3.8
- Installation method:
- Using daemon (yes/no):
- OS and version:
- Link to crash log:


Discussion:

Resolving patch:
diff --git a/flexget/plugins/internal/api_rottentomatoes.py b/flexget/plugins/internal/api_rottentomatoes.py
--- a/flexget/plugins/internal/api_rottentomatoes.py
+++ b/flexget/plugins/internal/api_rottentomatoes.py
@@ -32,7 +32,7 @@
 
 @db_schema.upgrade('api_rottentomatoes')
 def upgrade(ver, session):
-    if ver is 0:
+    if ver == 0:
         table_names = [
             'rottentomatoes_actors',
             'rottentomatoes_alternate_ids',
@@ -52,7 +52,7 @@ def upgrade(ver, session):
             session.execute(table.delete())
         table_add_column('rottentomatoes_actors', 'rt_id', String, session)
         ver = 1
-    if ver is 1:
+    if ver == 1:
         table = table_schema('rottentomatoes_search_results', session)
         session.execute(sql.delete(table, table.c.movie_id == None))
         ver = 2
@@ -289,7 +289,8 @@ def lookup_movie(
         year = title_parser.year
         if title == '' and not (rottentomatoes_id or title):
             raise PluginError('Failed to parse name from %s' % smart_match)
-
+    
+    search_string = ""
     if title:
         search_string = title.lower()
         if year:
@@ -298,7 +299,7 @@ def lookup_movie(
         raise PluginError('No criteria specified for rotten tomatoes lookup')
 
     def id_str():
-        return '<title=%s,year=%s,rottentomatoes_id=%s>' % (title, year, rottentomatoes_id)
+        return f'<title={title},year={year},rottentomatoes_id={rottentomatoes_id}>'
 
     logger.debug('Looking up rotten tomatoes information for {}', id_str())
 
diff --git a/update-changelog.py b/update-changelog.py
--- a/update-changelog.py
+++ b/update-changelog.py
@@ -45,7 +45,7 @@ def parse_message(self, message):
         for cat, item in self.change_items(message):
             found = True
             item = re.sub(
-                '#(\d{3,4})', r'[#\1](https://github.com/Flexget/Flexget/issues/\1)', item
+                r'#(\d{3,4})', r'[#\1](https://github.com/Flexget/Flexget/issues/\1)', item
             )
             item = '- {0}\n'.format(item)
             self.sections.setdefault(cat, ['\n']).insert(0, item)
@@ -54,7 +54,7 @@ def parse_message(self, message):
     def change_items(self, message):
         """An iterator of changelog updates from a commit message in the form (category, message)"""
         for line in message.split('\n'):
-            for cat_match in re.finditer('\[(\w+)\]', line):
+            for cat_match in re.finditer(r'\[(\w+)\]', line):
                 found_cat = self.cat_lookup(cat_match.group(1))
                 if found_cat:
                     line = line.replace(cat_match.group(0), '').strip()
@@ -105,10 +105,10 @@ def isplit(start_text, iterator):
 
     repo = Repo('.')
     cur_ver = MDChangeSet.from_md_lines(active_lines)
-    latestref = re.match('<!---\s*([\d\w]+)', start_comment).group(1)
-    oldestref = re.match('<!---\s*([\d\w]+)', end_comment).group(1)
+    latestref = re.match(r'<!---\s*([\d\w]+)', start_comment).group(1)
+    oldestref = re.match(r'<!---\s*([\d\w]+)', end_comment).group(1)
     released_vers = []
-    commits = list(repo.iter_commits('{0}..HEAD'.format(latestref), reverse=True))
+    commits = list(repo.iter_commits(f'{latestref}..HEAD', reverse=True))
     modified = False
     if commits:
         tags = {}
@@ -120,17 +120,17 @@ def isplit(start_text, iterator):
             if commit.hexsha in tags:
                 modified = True
                 # Tag changeset with release date and version and create new current changeset
-                version = tags[commit.hexsha].name.lstrip('v')
+                tag_name = tags[commit.hexsha].name
+                version = tag_name.lstrip('v')
                 release_date = tags[commit.hexsha].commit.committed_datetime.strftime('%Y-%m-%d')
-                cur_ver.version_header = '## {0} ({1})\n'.format(version, release_date)
+                cur_ver.version_header = f'## {version} ({release_date})\n'
                 diffstartref = oldestref
                 if oldestref in tags:
                     diffstartref = tags[oldestref].name
                 cur_ver.post_header.insert(
                     0,
-                    '[all commits](https://github.com/Flexget/Flexget/compare/{0}...{1})\n'.format(
-                        diffstartref, tags[commit.hexsha].name
-                    ),
+                    '[all commits]'
+                    f'(https://github.com/Flexget/Flexget/compare/{diffstartref}...{tag_name})\n'
                 )
                 released_vers.insert(0, cur_ver)
                 cur_ver = MDChangeSet()
@@ -142,7 +142,7 @@ def isplit(start_text, iterator):
                     exec(verfile)  # pylint: disable=W0122
                 except Exception:
                     pass
-                new_version_header = '## {0} (unreleased)\n'.format(__version__)
+                new_version_header = f'## {__version__} (unreleased)\n'
                 if new_version_header != cur_ver.version_header:
                     cur_ver.version_header = new_version_header
                     modified = True
@@ -151,9 +151,9 @@ def isplit(start_text, iterator):
         print('Writing modified changelog.')
         with open(filename, 'w', encoding='utf-8') as logfile:
             logfile.writelines(pre_lines)
-            logfile.write('<!---{0}--->\n'.format(commit.hexsha))
+            logfile.write(f'<!---{commit.hexsha}--->\n')
             logfile.writelines(cur_ver.to_md_lines())
-            logfile.write('<!---{0}--->\n'.format(oldestref))
+            logfile.write(f'<!---{oldestref}--->\n')
             for ver in released_vers:
                 logfile.writelines(ver.to_md_lines())
             logfile.writelines(post_lines)


Test patch: