Skip to content

Commit e6cfd6b

Browse files
Gergrobdimsdale
authored andcommitted
Clean up additional warnings spam
- 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.
1 parent 315ab98 commit e6cfd6b

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

extensions/composer/extension.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def read_exts_from_path(self, path):
9494
def pick_php_version(self, requested):
9595
selected = None
9696

97-
if requested is None or requested is '':
97+
if requested is None or requested == '':
9898
return self._ctx['PHP_VERSION']
9999

100100
# requested is coming from the composer.json file and is a unicode string type.

extensions/dynatrace/extension.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def update_agent_config(self):
260260

261261
# store static config in same kind of data structure (nested dictionary)
262262
# as we use for the config from we fetched from the API
263-
section_regex = re.compile('\[(.*)\]')
263+
section_regex = re.compile(r'\[(.*)\]')
264264
config_section = ""
265265
config_from_agent = dict()
266266
_log.debug("Starting to parse OneAgent config...")

extensions/sessions/extension.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ def _compile(self, install):
111111
# modify php.ini to contain the right session config
112112
self.load_config()
113113
self._php_ini.update_lines(
114-
'^session\.name = JSESSIONID$',
114+
r'^session\.name = JSESSIONID$',
115115
'session.name = PHPSESSIONID')
116116
self._php_ini.update_lines(
117-
'^session\.save_handler = files$',
117+
r'^session\.save_handler = files$',
118118
'session.save_handler = %s' % self.service.EXTENSION_NAME)
119119
self._php_ini.update_lines(
120-
'^session\.save_path = "@{TMPDIR}"$',
120+
r'^session\.save_path = "@{TMPDIR}"$',
121121
'session.save_path = "%s"' % self.service.session_save_path())
122122
self.service.custom_config_php_ini(self._php_ini)
123123
self._php_ini.save(self._php_ini_path)

tests/test_composer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def test_composer_tool_install(self):
7474
installer.package.return_value.done.assert_called_once()
7575
# make sure composer is installed
7676
installer._installer._install_binary_from_manifest.assert_called_once()
77-
assert re.match('/composer/[\d\.]+/composer.phar', installer._installer._install_binary_from_manifest.call_args[0][0]), \
77+
assert re.match(r'/composer/[\d\.]+/composer.phar', installer._installer._install_binary_from_manifest.call_args[0][0]), \
7878
"was %s" % installer._installer._install_binary_from_manifest.call_args[0][0]
7979

8080
def test_composer_tool_install_latest(self):

0 commit comments

Comments
 (0)