Skip to content

Commit

Permalink
Clean up additional warnings spam
Browse files Browse the repository at this point in the history
- Use raw strings (r'') for regexs. Otherwise the escape characters will
  be parsed by python, rather than being passed as part of the regex
  itself.
- Use "==" instead of "is" for checking string equality, rather than
  object equality. This technically works for small integers, because
  they have static object ids, but this is an implementation detail that
  shouldn't be depended on.
  • Loading branch information
Gerg authored and robdimsdale committed Sep 11, 2024
1 parent 315ab98 commit e6cfd6b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion extensions/composer/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def read_exts_from_path(self, path):
def pick_php_version(self, requested):
selected = None

if requested is None or requested is '':
if requested is None or requested == '':
return self._ctx['PHP_VERSION']

# requested is coming from the composer.json file and is a unicode string type.
Expand Down
2 changes: 1 addition & 1 deletion extensions/dynatrace/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def update_agent_config(self):

# store static config in same kind of data structure (nested dictionary)
# as we use for the config from we fetched from the API
section_regex = re.compile('\[(.*)\]')
section_regex = re.compile(r'\[(.*)\]')
config_section = ""
config_from_agent = dict()
_log.debug("Starting to parse OneAgent config...")
Expand Down
6 changes: 3 additions & 3 deletions extensions/sessions/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ def _compile(self, install):
# modify php.ini to contain the right session config
self.load_config()
self._php_ini.update_lines(
'^session\.name = JSESSIONID$',
r'^session\.name = JSESSIONID$',
'session.name = PHPSESSIONID')
self._php_ini.update_lines(
'^session\.save_handler = files$',
r'^session\.save_handler = files$',
'session.save_handler = %s' % self.service.EXTENSION_NAME)
self._php_ini.update_lines(
'^session\.save_path = "@{TMPDIR}"$',
r'^session\.save_path = "@{TMPDIR}"$',
'session.save_path = "%s"' % self.service.session_save_path())
self.service.custom_config_php_ini(self._php_ini)
self._php_ini.save(self._php_ini_path)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_composer_tool_install(self):
installer.package.return_value.done.assert_called_once()
# make sure composer is installed
installer._installer._install_binary_from_manifest.assert_called_once()
assert re.match('/composer/[\d\.]+/composer.phar', installer._installer._install_binary_from_manifest.call_args[0][0]), \
assert re.match(r'/composer/[\d\.]+/composer.phar', installer._installer._install_binary_from_manifest.call_args[0][0]), \
"was %s" % installer._installer._install_binary_from_manifest.call_args[0][0]

def test_composer_tool_install_latest(self):
Expand Down

0 comments on commit e6cfd6b

Please sign in to comment.