py2docfx 0.1.11rc1981066__py3-none-any.whl → 0.1.11rc1997820__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. py2docfx/__main__.py +24 -15
  2. py2docfx/convert_prepare/environment.py +13 -10
  3. py2docfx/convert_prepare/generate_document.py +6 -6
  4. py2docfx/convert_prepare/get_source.py +7 -7
  5. py2docfx/convert_prepare/git.py +10 -13
  6. py2docfx/convert_prepare/install_package.py +2 -2
  7. py2docfx/convert_prepare/pack.py +7 -10
  8. py2docfx/convert_prepare/package_info.py +3 -3
  9. py2docfx/convert_prepare/pip_utils.py +12 -14
  10. py2docfx/convert_prepare/post_process/merge_toc.py +3 -2
  11. py2docfx/convert_prepare/sphinx_caller.py +34 -12
  12. py2docfx/convert_prepare/tests/test_environment.py +0 -3
  13. py2docfx/convert_prepare/tests/test_generate_document.py +4 -2
  14. py2docfx/convert_prepare/tests/test_get_source.py +22 -14
  15. py2docfx/convert_prepare/tests/test_pack.py +6 -3
  16. py2docfx/convert_prepare/tests/test_params.py +0 -1
  17. py2docfx/convert_prepare/tests/test_sphinx_caller.py +10 -8
  18. py2docfx/convert_prepare/tests/test_subpackage.py +1 -0
  19. py2docfx/docfx_yaml/build_finished.py +1 -1
  20. py2docfx/docfx_yaml/logger.py +56 -55
  21. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/authorization_code.py +1 -1
  22. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/azd_cli.py +20 -14
  23. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/azure_arc.py +1 -1
  24. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/azure_cli.py +36 -14
  25. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/azure_powershell.py +1 -1
  26. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/chained.py +2 -2
  27. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/default.py +4 -3
  28. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/imds.py +2 -2
  29. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/managed_identity.py +1 -1
  30. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/__init__.py +2 -0
  31. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/auth_code_redirect_handler.py +1 -1
  32. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/decorators.py +15 -7
  33. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/interactive.py +1 -1
  34. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/managed_identity_client.py +0 -1
  35. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/msal_client.py +1 -1
  36. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/msal_managed_identity_client.py +2 -1
  37. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/shared_token_cache.py +3 -3
  38. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/utils.py +17 -2
  39. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_version.py +1 -1
  40. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/azd_cli.py +14 -11
  41. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/azure_cli.py +30 -12
  42. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/default.py +2 -2
  43. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/imds.py +3 -3
  44. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/managed_identity.py +1 -1
  45. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_internal/decorators.py +15 -7
  46. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_internal/managed_identity_client.py +1 -1
  47. py2docfx/venv/venv1/Lib/site-packages/cryptography/__about__.py +1 -1
  48. py2docfx/venv/venv1/Lib/site-packages/google/api/annotations_pb2.py +7 -4
  49. py2docfx/venv/venv1/Lib/site-packages/google/api/auth_pb2.py +6 -3
  50. py2docfx/venv/venv1/Lib/site-packages/google/api/backend_pb2.py +14 -7
  51. py2docfx/venv/venv1/Lib/site-packages/google/api/billing_pb2.py +6 -3
  52. py2docfx/venv/venv1/Lib/site-packages/google/api/client_pb2.py +47 -38
  53. py2docfx/venv/venv1/Lib/site-packages/google/api/config_change_pb2.py +6 -3
  54. py2docfx/venv/venv1/Lib/site-packages/google/api/consumer_pb2.py +6 -3
  55. py2docfx/venv/venv1/Lib/site-packages/google/api/context_pb2.py +6 -3
  56. py2docfx/venv/venv1/Lib/site-packages/google/api/control_pb2.py +6 -4
  57. py2docfx/venv/venv1/Lib/site-packages/google/api/distribution_pb2.py +7 -5
  58. py2docfx/venv/venv1/Lib/site-packages/google/api/documentation_pb2.py +6 -3
  59. py2docfx/venv/venv1/Lib/site-packages/google/api/endpoint_pb2.py +6 -3
  60. py2docfx/venv/venv1/Lib/site-packages/google/api/error_reason_pb2.py +6 -3
  61. py2docfx/venv/venv1/Lib/site-packages/google/api/field_behavior_pb2.py +8 -6
  62. py2docfx/venv/venv1/Lib/site-packages/google/api/field_info_pb2.py +6 -4
  63. py2docfx/venv/venv1/Lib/site-packages/google/api/http_pb2.py +7 -4
  64. py2docfx/venv/venv1/Lib/site-packages/google/api/httpbody_pb2.py +6 -4
  65. py2docfx/venv/venv1/Lib/site-packages/google/api/label_pb2.py +7 -4
  66. py2docfx/venv/venv1/Lib/site-packages/google/api/launch_stage_pb2.py +6 -3
  67. py2docfx/venv/venv1/Lib/site-packages/google/api/log_pb2.py +6 -4
  68. py2docfx/venv/venv1/Lib/site-packages/google/api/logging_pb2.py +6 -3
  69. py2docfx/venv/venv1/Lib/site-packages/google/api/metric_pb2.py +12 -9
  70. py2docfx/venv/venv1/Lib/site-packages/google/api/monitored_resource_pb2.py +15 -10
  71. py2docfx/venv/venv1/Lib/site-packages/google/api/monitoring_pb2.py +6 -3
  72. py2docfx/venv/venv1/Lib/site-packages/google/api/policy_pb2.py +7 -5
  73. py2docfx/venv/venv1/Lib/site-packages/google/api/quota_pb2.py +10 -7
  74. py2docfx/venv/venv1/Lib/site-packages/google/api/resource_pb2.py +7 -5
  75. py2docfx/venv/venv1/Lib/site-packages/google/api/routing_pb2.py +6 -4
  76. py2docfx/venv/venv1/Lib/site-packages/google/api/service_pb2.py +15 -12
  77. py2docfx/venv/venv1/Lib/site-packages/google/api/source_info_pb2.py +6 -4
  78. py2docfx/venv/venv1/Lib/site-packages/google/api/system_parameter_pb2.py +6 -3
  79. py2docfx/venv/venv1/Lib/site-packages/google/api/usage_pb2.py +6 -3
  80. py2docfx/venv/venv1/Lib/site-packages/google/api/visibility_pb2.py +7 -5
  81. py2docfx/venv/venv1/Lib/site-packages/google/cloud/extended_operations_pb2.py +6 -4
  82. py2docfx/venv/venv1/Lib/site-packages/google/cloud/location/locations_pb2.py +18 -13
  83. py2docfx/venv/venv1/Lib/site-packages/google/gapic/metadata/gapic_metadata_pb2.py +31 -26
  84. py2docfx/venv/venv1/Lib/site-packages/google/logging/type/http_request_pb2.py +6 -4
  85. py2docfx/venv/venv1/Lib/site-packages/google/logging/type/log_severity_pb2.py +6 -3
  86. py2docfx/venv/venv1/Lib/site-packages/google/longrunning/operations_grpc.py +2 -1
  87. py2docfx/venv/venv1/Lib/site-packages/google/longrunning/operations_grpc_pb2.py +11 -10
  88. py2docfx/venv/venv1/Lib/site-packages/google/longrunning/operations_pb2.py +20 -17
  89. py2docfx/venv/venv1/Lib/site-packages/google/longrunning/operations_pb2_grpc.py +1 -2
  90. py2docfx/venv/venv1/Lib/site-packages/google/longrunning/operations_proto.py +2 -1
  91. py2docfx/venv/venv1/Lib/site-packages/google/longrunning/operations_proto_pb2.py +22 -19
  92. py2docfx/venv/venv1/Lib/site-packages/google/rpc/code_pb2.py +6 -3
  93. py2docfx/venv/venv1/Lib/site-packages/google/rpc/context/attribute_context_pb2.py +20 -16
  94. py2docfx/venv/venv1/Lib/site-packages/google/rpc/context/audit_context_pb2.py +7 -5
  95. py2docfx/venv/venv1/Lib/site-packages/google/rpc/error_details_pb2.py +21 -19
  96. py2docfx/venv/venv1/Lib/site-packages/google/rpc/http_pb2.py +6 -3
  97. py2docfx/venv/venv1/Lib/site-packages/google/rpc/status_pb2.py +6 -4
  98. py2docfx/venv/venv1/Lib/site-packages/google/type/calendar_period_pb2.py +6 -3
  99. py2docfx/venv/venv1/Lib/site-packages/google/type/color_pb2.py +6 -4
  100. py2docfx/venv/venv1/Lib/site-packages/google/type/date_pb2.py +6 -3
  101. py2docfx/venv/venv1/Lib/site-packages/google/type/datetime_pb2.py +6 -4
  102. py2docfx/venv/venv1/Lib/site-packages/google/type/dayofweek_pb2.py +6 -3
  103. py2docfx/venv/venv1/Lib/site-packages/google/type/decimal_pb2.py +6 -3
  104. py2docfx/venv/venv1/Lib/site-packages/google/type/expr_pb2.py +6 -3
  105. py2docfx/venv/venv1/Lib/site-packages/google/type/fraction_pb2.py +6 -3
  106. py2docfx/venv/venv1/Lib/site-packages/google/type/interval_pb2.py +6 -4
  107. py2docfx/venv/venv1/Lib/site-packages/google/type/latlng_pb2.py +6 -3
  108. py2docfx/venv/venv1/Lib/site-packages/google/type/localized_text_pb2.py +6 -3
  109. py2docfx/venv/venv1/Lib/site-packages/google/type/money_pb2.py +6 -3
  110. py2docfx/venv/venv1/Lib/site-packages/google/type/month_pb2.py +6 -3
  111. py2docfx/venv/venv1/Lib/site-packages/google/type/phone_number_pb2.py +6 -3
  112. py2docfx/venv/venv1/Lib/site-packages/google/type/postal_address_pb2.py +6 -3
  113. py2docfx/venv/venv1/Lib/site-packages/google/type/quaternion_pb2.py +6 -3
  114. py2docfx/venv/venv1/Lib/site-packages/google/type/timeofday_pb2.py +6 -3
  115. py2docfx/venv/venv1/Lib/site-packages/psutil/__init__.py +122 -201
  116. py2docfx/venv/venv1/Lib/site-packages/psutil/_common.py +84 -128
  117. py2docfx/venv/venv1/Lib/site-packages/psutil/_psaix.py +24 -38
  118. py2docfx/venv/venv1/Lib/site-packages/psutil/_psbsd.py +44 -58
  119. py2docfx/venv/venv1/Lib/site-packages/psutil/_pslinux.py +170 -254
  120. py2docfx/venv/venv1/Lib/site-packages/psutil/_psosx.py +8 -16
  121. py2docfx/venv/venv1/Lib/site-packages/psutil/_psposix.py +13 -49
  122. py2docfx/venv/venv1/Lib/site-packages/psutil/_pssunos.py +41 -60
  123. py2docfx/venv/venv1/Lib/site-packages/psutil/_pswindows.py +75 -145
  124. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/__init__.py +105 -193
  125. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_aix.py +2 -2
  126. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_bsd.py +27 -26
  127. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_connections.py +16 -17
  128. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_contracts.py +5 -19
  129. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_linux.py +153 -211
  130. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_memleaks.py +0 -6
  131. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_misc.py +22 -207
  132. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_osx.py +9 -4
  133. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_posix.py +8 -15
  134. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_process.py +104 -184
  135. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_process_all.py +28 -36
  136. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_scripts.py +240 -0
  137. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_sunos.py +1 -1
  138. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_system.py +44 -50
  139. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_testutils.py +23 -33
  140. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_unicode.py +8 -67
  141. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_windows.py +32 -52
  142. {py2docfx-0.1.11rc1981066.dist-info → py2docfx-0.1.11rc1997820.dist-info}/METADATA +1 -1
  143. {py2docfx-0.1.11rc1981066.dist-info → py2docfx-0.1.11rc1997820.dist-info}/RECORD +145 -145
  144. py2docfx/venv/venv1/Lib/site-packages/psutil/_compat.py +0 -477
  145. {py2docfx-0.1.11rc1981066.dist-info → py2docfx-0.1.11rc1997820.dist-info}/WHEEL +0 -0
  146. {py2docfx-0.1.11rc1981066.dist-info → py2docfx-0.1.11rc1997820.dist-info}/top_level.txt +0 -0
@@ -31,7 +31,7 @@ class AIXSpecificTestCase(PsutilTestCase):
31
31
  "available",
32
32
  "mmode",
33
33
  ]:
34
- re_pattern += r"(?P<%s>\S+)\s+" % (field,)
34
+ re_pattern += rf"(?P<{field}>\S+)\s+"
35
35
  matchobj = re.search(re_pattern, out)
36
36
 
37
37
  assert matchobj is not None
@@ -104,7 +104,7 @@ class AIXSpecificTestCase(PsutilTestCase):
104
104
  "S5rd",
105
105
  "sysc",
106
106
  ]:
107
- re_pattern += r"(?P<%s>\S+)\s+" % (field,)
107
+ re_pattern += rf"(?P<{field}>\S+)\s+"
108
108
  matchobj = re.search(re_pattern, out)
109
109
 
110
110
  assert matchobj is not None
@@ -9,10 +9,10 @@
9
9
 
10
10
  """Tests specific to all BSD platforms."""
11
11
 
12
-
13
12
  import datetime
14
13
  import os
15
14
  import re
15
+ import shutil
16
16
  import time
17
17
 
18
18
  import psutil
@@ -28,7 +28,6 @@ from psutil.tests import retry_on_failure
28
28
  from psutil.tests import sh
29
29
  from psutil.tests import spawn_testproc
30
30
  from psutil.tests import terminate
31
- from psutil.tests import which
32
31
 
33
32
 
34
33
  if BSD:
@@ -36,7 +35,7 @@ if BSD:
36
35
 
37
36
  PAGESIZE = getpagesize()
38
37
  # muse requires root privileges
39
- MUSE_AVAILABLE = os.getuid() == 0 and which('muse')
38
+ MUSE_AVAILABLE = os.getuid() == 0 and shutil.which("muse")
40
39
  else:
41
40
  PAGESIZE = None
42
41
  MUSE_AVAILABLE = False
@@ -87,7 +86,7 @@ class BSDTestCase(PsutilTestCase):
87
86
 
88
87
  @pytest.mark.skipif(NETBSD, reason="-o lstart doesn't work on NETBSD")
89
88
  def test_process_create_time(self):
90
- output = sh("ps -o lstart -p %s" % self.pid)
89
+ output = sh(f"ps -o lstart -p {self.pid}")
91
90
  start_ps = output.replace('STARTED', '').strip()
92
91
  start_psutil = psutil.Process(self.pid).create_time()
93
92
  start_psutil = time.strftime(
@@ -99,7 +98,7 @@ class BSDTestCase(PsutilTestCase):
99
98
  # test psutil.disk_usage() and psutil.disk_partitions()
100
99
  # against "df -a"
101
100
  def df(path):
102
- out = sh('df -k "%s"' % path).strip()
101
+ out = sh(f'df -k "{path}"').strip()
103
102
  lines = out.split('\n')
104
103
  lines.pop(0)
105
104
  line = lines.pop(0)
@@ -118,16 +117,20 @@ class BSDTestCase(PsutilTestCase):
118
117
  assert usage.total == total
119
118
  # 10 MB tolerance
120
119
  if abs(usage.free - free) > 10 * 1024 * 1024:
121
- raise self.fail("psutil=%s, df=%s" % (usage.free, free))
120
+ raise self.fail(f"psutil={usage.free}, df={free}")
122
121
  if abs(usage.used - used) > 10 * 1024 * 1024:
123
- raise self.fail("psutil=%s, df=%s" % (usage.used, used))
122
+ raise self.fail(f"psutil={usage.used}, df={used}")
124
123
 
125
- @pytest.mark.skipif(not which('sysctl'), reason="sysctl cmd not available")
124
+ @pytest.mark.skipif(
125
+ not shutil.which("sysctl"), reason="sysctl cmd not available"
126
+ )
126
127
  def test_cpu_count_logical(self):
127
128
  syst = sysctl("hw.ncpu")
128
129
  assert psutil.cpu_count(logical=True) == syst
129
130
 
130
- @pytest.mark.skipif(not which('sysctl'), reason="sysctl cmd not available")
131
+ @pytest.mark.skipif(
132
+ not shutil.which("sysctl"), reason="sysctl cmd not available"
133
+ )
131
134
  @pytest.mark.skipif(
132
135
  NETBSD, reason="skipped on NETBSD" # we check /proc/meminfo
133
136
  )
@@ -136,12 +139,12 @@ class BSDTestCase(PsutilTestCase):
136
139
  assert num == psutil.virtual_memory().total
137
140
 
138
141
  @pytest.mark.skipif(
139
- not which('ifconfig'), reason="ifconfig cmd not available"
142
+ not shutil.which("ifconfig"), reason="ifconfig cmd not available"
140
143
  )
141
144
  def test_net_if_stats(self):
142
145
  for name, stats in psutil.net_if_stats().items():
143
146
  try:
144
- out = sh("ifconfig %s" % name)
147
+ out = sh(f"ifconfig {name}")
145
148
  except RuntimeError:
146
149
  pass
147
150
  else:
@@ -167,7 +170,7 @@ class FreeBSDPsutilTestCase(PsutilTestCase):
167
170
 
168
171
  @retry_on_failure()
169
172
  def test_memory_maps(self):
170
- out = sh('procstat -v %s' % self.pid)
173
+ out = sh(f"procstat -v {self.pid}")
171
174
  maps = psutil.Process(self.pid).memory_maps(grouped=False)
172
175
  lines = out.split('\n')[1:]
173
176
  while lines:
@@ -175,23 +178,23 @@ class FreeBSDPsutilTestCase(PsutilTestCase):
175
178
  fields = line.split()
176
179
  _, start, stop, _perms, res = fields[:5]
177
180
  map = maps.pop()
178
- assert "%s-%s" % (start, stop) == map.addr
181
+ assert f"{start}-{stop}" == map.addr
179
182
  assert int(res) == map.rss
180
183
  if not map.path.startswith('['):
181
184
  assert fields[10] == map.path
182
185
 
183
186
  def test_exe(self):
184
- out = sh('procstat -b %s' % self.pid)
187
+ out = sh(f"procstat -b {self.pid}")
185
188
  assert psutil.Process(self.pid).exe() == out.split('\n')[1].split()[-1]
186
189
 
187
190
  def test_cmdline(self):
188
- out = sh('procstat -c %s' % self.pid)
191
+ out = sh(f"procstat -c {self.pid}")
189
192
  assert ' '.join(psutil.Process(self.pid).cmdline()) == ' '.join(
190
193
  out.split('\n')[1].split()[2:]
191
194
  )
192
195
 
193
196
  def test_uids_gids(self):
194
- out = sh('procstat -s %s' % self.pid)
197
+ out = sh(f"procstat -s {self.pid}")
195
198
  euid, ruid, suid, egid, rgid, sgid = out.split('\n')[1].split()[2:8]
196
199
  p = psutil.Process(self.pid)
197
200
  uids = p.uids()
@@ -206,7 +209,7 @@ class FreeBSDPsutilTestCase(PsutilTestCase):
206
209
  @retry_on_failure()
207
210
  def test_ctx_switches(self):
208
211
  tested = []
209
- out = sh('procstat -r %s' % self.pid)
212
+ out = sh(f"procstat -r {self.pid}")
210
213
  p = psutil.Process(self.pid)
211
214
  for line in out.split('\n'):
212
215
  line = line.lower().strip()
@@ -226,7 +229,7 @@ class FreeBSDPsutilTestCase(PsutilTestCase):
226
229
  @retry_on_failure()
227
230
  def test_cpu_times(self):
228
231
  tested = []
229
- out = sh('procstat -r %s' % self.pid)
232
+ out = sh(f"procstat -r {self.pid}")
230
233
  p = psutil.Process(self.pid)
231
234
  for line in out.split('\n'):
232
235
  line = line.lower().strip()
@@ -253,7 +256,7 @@ class FreeBSDSystemTestCase(PsutilTestCase):
253
256
  parts = re.split(r'\s+', output)
254
257
 
255
258
  if not parts:
256
- raise ValueError("Can't parse swapinfo: %s" % output)
259
+ raise ValueError(f"Can't parse swapinfo: {output}")
257
260
 
258
261
  # the size is in 1k units, so multiply by 1024
259
262
  total, used, free = (int(p) * 1024 for p in parts[1:4])
@@ -420,12 +423,10 @@ class FreeBSDSystemTestCase(PsutilTestCase):
420
423
  def secs2hours(secs):
421
424
  m, _s = divmod(secs, 60)
422
425
  h, m = divmod(m, 60)
423
- return "%d:%02d" % (h, m)
426
+ return f"{int(h)}:{int(m):02}"
424
427
 
425
428
  out = sh("acpiconf -i 0")
426
- fields = dict(
427
- [(x.split('\t')[0], x.split('\t')[-1]) for x in out.split("\n")]
428
- )
429
+ fields = {x.split('\t')[0]: x.split('\t')[-1] for x in out.split("\n")}
429
430
  metrics = psutil.sensors_battery()
430
431
  percent = int(fields['Remaining capacity:'].replace('%', ''))
431
432
  remaining_time = fields['Remaining time:']
@@ -465,7 +466,7 @@ class FreeBSDSystemTestCase(PsutilTestCase):
465
466
  def test_sensors_temperatures_against_sysctl(self):
466
467
  num_cpus = psutil.cpu_count(True)
467
468
  for cpu in range(num_cpus):
468
- sensor = "dev.cpu.%s.temperature" % cpu
469
+ sensor = f"dev.cpu.{cpu}.temperature"
469
470
  # sysctl returns a string in the format 46.0C
470
471
  try:
471
472
  sysctl_result = int(float(sysctl(sensor)[:-1]))
@@ -479,7 +480,7 @@ class FreeBSDSystemTestCase(PsutilTestCase):
479
480
  < 10
480
481
  )
481
482
 
482
- sensor = "dev.cpu.%s.coretemp.tjmax" % cpu
483
+ sensor = f"dev.cpu.{cpu}.coretemp.tjmax"
483
484
  sysctl_result = int(float(sysctl(sensor)[:-1]))
484
485
  assert (
485
486
  psutil.sensors_temperatures()["coretemp"][cpu].high
@@ -514,7 +515,7 @@ class NetBSDTestCase(PsutilTestCase):
514
515
  for line in f:
515
516
  if line.startswith(look_for):
516
517
  return int(line.split()[1]) * 1024
517
- raise ValueError("can't find %s" % look_for)
518
+ raise ValueError(f"can't find {look_for}")
518
519
 
519
520
  # --- virtual mem
520
521
 
@@ -25,7 +25,6 @@ from psutil import POSIX
25
25
  from psutil import SUNOS
26
26
  from psutil import WINDOWS
27
27
  from psutil._common import supports_ipv6
28
- from psutil._compat import PY3
29
28
  from psutil.tests import AF_UNIX
30
29
  from psutil.tests import HAS_NET_CONNECTIONS_UNIX
31
30
  from psutil.tests import SKIP_SYSCONS
@@ -109,7 +108,7 @@ class TestUnconnectedSockets(ConnectionTestCase):
109
108
 
110
109
  def get_conn_from_sock(self, sock):
111
110
  cons = this_proc_net_connections(kind='all')
112
- smap = dict([(c.fd, c) for c in cons])
111
+ smap = {c.fd: c for c in cons}
113
112
  if NETBSD or FREEBSD:
114
113
  # NetBSD opens a UNIX socket to /var/log/run
115
114
  # so there may be more connections.
@@ -137,7 +136,7 @@ class TestUnconnectedSockets(ConnectionTestCase):
137
136
 
138
137
  # local address
139
138
  laddr = sock.getsockname()
140
- if not laddr and PY3 and isinstance(laddr, bytes):
139
+ if not laddr and isinstance(laddr, bytes):
141
140
  # See: http://bugs.python.org/issue30205
142
141
  laddr = laddr.decode()
143
142
  if sock.family == AF_INET6:
@@ -185,7 +184,7 @@ class TestUnconnectedSockets(ConnectionTestCase):
185
184
  testfn = self.get_testfn()
186
185
  with closing(bind_unix_socket(testfn, type=SOCK_STREAM)) as sock:
187
186
  conn = self.check_socket(sock)
188
- assert conn.raddr == "" # noqa
187
+ assert conn.raddr == ""
189
188
  assert conn.status == psutil.CONN_NONE
190
189
 
191
190
  @pytest.mark.skipif(not POSIX, reason="POSIX only")
@@ -193,7 +192,7 @@ class TestUnconnectedSockets(ConnectionTestCase):
193
192
  testfn = self.get_testfn()
194
193
  with closing(bind_unix_socket(testfn, type=SOCK_STREAM)) as sock:
195
194
  conn = self.check_socket(sock)
196
- assert conn.raddr == "" # noqa
195
+ assert conn.raddr == ""
197
196
  assert conn.status == psutil.CONN_NONE
198
197
 
199
198
 
@@ -240,8 +239,8 @@ class TestConnectedSocket(ConnectionTestCase):
240
239
  assert len(cons) == 2
241
240
  if LINUX or FREEBSD or SUNOS or OPENBSD:
242
241
  # remote path is never set
243
- assert cons[0].raddr == "" # noqa
244
- assert cons[1].raddr == "" # noqa
242
+ assert cons[0].raddr == ""
243
+ assert cons[1].raddr == ""
245
244
  # one local address should though
246
245
  assert testfn == (cons[0].laddr or cons[1].laddr)
247
246
  else:
@@ -357,14 +356,14 @@ class TestFilters(ConnectionTestCase):
357
356
  # launch various subprocess instantiating a socket of various
358
357
  # families and types to enrich psutil results
359
358
  tcp4_proc = self.pyrun(tcp4_template)
360
- tcp4_addr = eval(wait_for_file(testfile, delete=True)) # noqa
359
+ tcp4_addr = eval(wait_for_file(testfile, delete=True))
361
360
  udp4_proc = self.pyrun(udp4_template)
362
- udp4_addr = eval(wait_for_file(testfile, delete=True)) # noqa
361
+ udp4_addr = eval(wait_for_file(testfile, delete=True))
363
362
  if supports_ipv6():
364
363
  tcp6_proc = self.pyrun(tcp6_template)
365
- tcp6_addr = eval(wait_for_file(testfile, delete=True)) # noqa
364
+ tcp6_addr = eval(wait_for_file(testfile, delete=True))
366
365
  udp6_proc = self.pyrun(udp6_template)
367
- udp6_addr = eval(wait_for_file(testfile, delete=True)) # noqa
366
+ udp6_addr = eval(wait_for_file(testfile, delete=True))
368
367
  else:
369
368
  tcp6_proc = None
370
369
  udp6_proc = None
@@ -523,14 +522,14 @@ class TestSystemWideConnections(ConnectionTestCase):
523
522
  for _ in range(times):
524
523
  fname = self.get_testfn()
525
524
  fnames.append(fname)
526
- src = textwrap.dedent("""\
525
+ src = textwrap.dedent(f"""\
527
526
  import time, os
528
527
  from psutil.tests import create_sockets
529
528
  with create_sockets():
530
- with open(r'%s', 'w') as f:
529
+ with open(r'{fname}', 'w') as f:
531
530
  f.write("hello")
532
531
  [time.sleep(0.1) for x in range(100)]
533
- """ % fname)
532
+ """)
534
533
  sproc = self.pyrun(src)
535
534
  pids.append(sproc.pid)
536
535
 
@@ -561,7 +560,7 @@ class TestMisc(PsutilTestCase):
561
560
  ints.append(num)
562
561
  strs.append(str_)
563
562
  if SUNOS:
564
- psutil.CONN_IDLE # noqa
565
- psutil.CONN_BOUND # noqa
563
+ psutil.CONN_IDLE # noqa: B018
564
+ psutil.CONN_BOUND # noqa: B018
566
565
  if WINDOWS:
567
- psutil.CONN_DELETE_TCB # noqa
566
+ psutil.CONN_DELETE_TCB # noqa: B018
@@ -22,14 +22,11 @@ from psutil import OPENBSD
22
22
  from psutil import POSIX
23
23
  from psutil import SUNOS
24
24
  from psutil import WINDOWS
25
- from psutil._compat import long
26
25
  from psutil.tests import GITHUB_ACTIONS
27
26
  from psutil.tests import HAS_CPU_FREQ
28
27
  from psutil.tests import HAS_NET_IO_COUNTERS
29
28
  from psutil.tests import HAS_SENSORS_FANS
30
29
  from psutil.tests import HAS_SENSORS_TEMPERATURES
31
- from psutil.tests import PYPY
32
- from psutil.tests import QEMU_USER
33
30
  from psutil.tests import SKIP_SYSCONS
34
31
  from psutil.tests import PsutilTestCase
35
32
  from psutil.tests import create_sockets
@@ -198,7 +195,6 @@ class TestAvailProcessAPIs(PsutilTestCase):
198
195
 
199
196
  class TestSystemAPITypes(PsutilTestCase):
200
197
  """Check the return types of system related APIs.
201
- Mainly we want to test we never return unicode on Python 2, see:
202
198
  https://github.com/giampaolo/psutil/issues/1039.
203
199
  """
204
200
 
@@ -237,13 +233,13 @@ class TestSystemAPITypes(PsutilTestCase):
237
233
  def test_cpu_freq(self):
238
234
  if psutil.cpu_freq() is None:
239
235
  raise pytest.skip("cpu_freq() returns None")
240
- self.assert_ntuple_of_nums(psutil.cpu_freq(), type_=(float, int, long))
236
+ self.assert_ntuple_of_nums(psutil.cpu_freq(), type_=(float, int))
241
237
 
242
238
  def test_disk_io_counters(self):
243
239
  # Duplicate of test_system.py. Keep it anyway.
244
240
  for k, v in psutil.disk_io_counters(perdisk=True).items():
245
241
  assert isinstance(k, str)
246
- self.assert_ntuple_of_nums(v, type_=(int, long))
242
+ self.assert_ntuple_of_nums(v, type_=int)
247
243
 
248
244
  def test_disk_partitions(self):
249
245
  # Duplicate of test_system.py. Keep it anyway.
@@ -266,24 +262,17 @@ class TestSystemAPITypes(PsutilTestCase):
266
262
  for ifname, addrs in psutil.net_if_addrs().items():
267
263
  assert isinstance(ifname, str)
268
264
  for addr in addrs:
269
- if enum is not None and not PYPY:
270
- assert isinstance(addr.family, enum.IntEnum)
271
- else:
272
- assert isinstance(addr.family, int)
265
+ assert isinstance(addr.family, enum.IntEnum)
273
266
  assert isinstance(addr.address, str)
274
267
  assert isinstance(addr.netmask, (str, type(None)))
275
268
  assert isinstance(addr.broadcast, (str, type(None)))
276
269
 
277
- @pytest.mark.skipif(QEMU_USER, reason="QEMU user not supported")
278
270
  def test_net_if_stats(self):
279
271
  # Duplicate of test_system.py. Keep it anyway.
280
272
  for ifname, info in psutil.net_if_stats().items():
281
273
  assert isinstance(ifname, str)
282
274
  assert isinstance(info.isup, bool)
283
- if enum is not None:
284
- assert isinstance(info.duplex, enum.IntEnum)
285
- else:
286
- assert isinstance(info.duplex, int)
275
+ assert isinstance(info.duplex, enum.IntEnum)
287
276
  assert isinstance(info.speed, int)
288
277
  assert isinstance(info.mtu, int)
289
278
 
@@ -333,7 +322,4 @@ class TestProcessWaitType(PsutilTestCase):
333
322
  p.terminate()
334
323
  code = p.wait()
335
324
  assert code == -signal.SIGTERM
336
- if enum is not None:
337
- assert isinstance(code, enum.IntEnum)
338
- else:
339
- assert isinstance(code, int)
325
+ assert isinstance(code, enum.IntEnum)