prospector 1.10.0__py3-none-any.whl → 1.13.2__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 (52) hide show
  1. prospector/autodetect.py +10 -9
  2. prospector/blender.py +18 -12
  3. prospector/config/__init__.py +66 -49
  4. prospector/config/configuration.py +17 -14
  5. prospector/config/datatype.py +1 -1
  6. prospector/encoding.py +2 -2
  7. prospector/exceptions.py +1 -6
  8. prospector/finder.py +9 -8
  9. prospector/formatters/__init__.py +1 -1
  10. prospector/formatters/base.py +17 -11
  11. prospector/formatters/base_summary.py +43 -0
  12. prospector/formatters/emacs.py +5 -5
  13. prospector/formatters/grouped.py +9 -7
  14. prospector/formatters/json.py +3 -2
  15. prospector/formatters/pylint.py +41 -9
  16. prospector/formatters/text.py +10 -58
  17. prospector/formatters/vscode.py +17 -7
  18. prospector/formatters/xunit.py +6 -7
  19. prospector/formatters/yaml.py +4 -2
  20. prospector/message.py +32 -14
  21. prospector/pathutils.py +3 -10
  22. prospector/postfilter.py +9 -8
  23. prospector/profiles/exceptions.py +14 -11
  24. prospector/profiles/profile.py +70 -59
  25. prospector/run.py +20 -18
  26. prospector/suppression.py +19 -13
  27. prospector/tools/__init__.py +19 -13
  28. prospector/tools/bandit/__init__.py +27 -15
  29. prospector/tools/base.py +11 -3
  30. prospector/tools/dodgy/__init__.py +7 -3
  31. prospector/tools/mccabe/__init__.py +13 -6
  32. prospector/tools/mypy/__init__.py +44 -76
  33. prospector/tools/profile_validator/__init__.py +24 -15
  34. prospector/tools/pycodestyle/__init__.py +22 -15
  35. prospector/tools/pydocstyle/__init__.py +12 -6
  36. prospector/tools/pyflakes/__init__.py +35 -19
  37. prospector/tools/pylint/__init__.py +57 -31
  38. prospector/tools/pylint/collector.py +3 -5
  39. prospector/tools/pylint/linter.py +19 -14
  40. prospector/tools/pyright/__init__.py +18 -7
  41. prospector/tools/pyroma/__init__.py +10 -6
  42. prospector/tools/ruff/__init__.py +84 -0
  43. prospector/tools/utils.py +25 -19
  44. prospector/tools/vulture/__init__.py +25 -15
  45. {prospector-1.10.0.dist-info → prospector-1.13.2.dist-info}/METADATA +13 -14
  46. prospector-1.13.2.dist-info/RECORD +71 -0
  47. README.rst +0 -208
  48. prospector-1.10.0.dist-info/LICENSE +0 -339
  49. prospector-1.10.0.dist-info/RECORD +0 -71
  50. /LICENSE → /prospector-1.13.2.dist-info/LICENSE +0 -0
  51. {prospector-1.10.0.dist-info → prospector-1.13.2.dist-info}/WHEEL +0 -0
  52. {prospector-1.10.0.dist-info → prospector-1.13.2.dist-info}/entry_points.txt +0 -0
@@ -1,19 +1,27 @@
1
+ from collections.abc import Iterable
2
+ from pathlib import Path
3
+ from typing import TYPE_CHECKING, Any, Optional
4
+
1
5
  from vulture import Vulture
2
6
 
3
7
  from prospector.encoding import CouldNotHandleEncoding, read_py_file
8
+ from prospector.finder import FileFinder
4
9
  from prospector.message import Location, Message, make_tool_error_message
5
10
  from prospector.tools.base import ToolBase
6
11
 
12
+ if TYPE_CHECKING:
13
+ from prospector.config import ProspectorConfig
14
+
7
15
 
8
16
  class ProspectorVulture(Vulture):
9
- def __init__(self, found_files):
17
+ def __init__(self, found_files: FileFinder) -> None:
10
18
  Vulture.__init__(self, verbose=False)
11
19
  self._files = found_files
12
- self._internal_messages = []
13
- self.file = None
14
- self.filename = None
20
+ self._internal_messages: list[Message] = []
21
+ self.file: Optional[Path] = None
22
+ self.filename: Optional[Path] = None
15
23
 
16
- def scavenge(self, _=None, __=None):
24
+ def scavenge(self, _: Any = None, __: Any = None) -> None:
17
25
  # The argument is a list of paths, but we don't care
18
26
  # about that as we use the found_files object. The
19
27
  # argument is here to explicitly acknowledge that we
@@ -27,7 +35,9 @@ class ProspectorVulture(Vulture):
27
35
  module,
28
36
  "vulture",
29
37
  "V000",
30
- message=f"Could not handle the encoding of this file: {err.encoding}",
38
+ message=(
39
+ f"Could not handle the encoding of this file: {err.encoding}" # type: ignore[attr-defined]
40
+ ),
31
41
  )
32
42
  )
33
43
  continue
@@ -38,7 +48,7 @@ class ProspectorVulture(Vulture):
38
48
  except TypeError:
39
49
  self.scan(module_string)
40
50
 
41
- def get_messages(self):
51
+ def get_messages(self) -> list[Message]:
42
52
  all_items = (
43
53
  ("unused-function", "Unused function %s", self.unused_funcs),
44
54
  ("unused-property", "Unused property %s", self.unused_props),
@@ -53,10 +63,7 @@ class ProspectorVulture(Vulture):
53
63
  filename = item.file
54
64
  except AttributeError:
55
65
  filename = item.filename
56
- if hasattr(item, "lineno"):
57
- lineno = item.lineno # for older versions of vulture
58
- else:
59
- lineno = item.first_lineno
66
+ lineno = item.lineno if hasattr(item, "lineno") else item.first_lineno
60
67
  loc = Location(filename, None, None, lineno, -1)
61
68
  message_text = template % item
62
69
  message = Message("vulture", code, loc, message_text)
@@ -66,15 +73,18 @@ class ProspectorVulture(Vulture):
66
73
 
67
74
 
68
75
  class VultureTool(ToolBase):
69
- def __init__(self):
76
+ def __init__(self) -> None:
70
77
  ToolBase.__init__(self)
71
78
  self._vulture = None
72
- self.ignore_codes = ()
79
+ self.ignore_codes: list[str] = []
73
80
 
74
- def configure(self, prospector_config, found_files):
81
+ def configure( # pylint: disable=useless-return
82
+ self, prospector_config: "ProspectorConfig", found_files: FileFinder
83
+ ) -> Optional[tuple[Optional[str], Optional[Iterable[Message]]]]:
75
84
  self.ignore_codes = prospector_config.get_disabled_messages("vulture")
85
+ return None
76
86
 
77
- def run(self, found_files):
87
+ def run(self, found_files: FileFinder) -> list[Message]:
78
88
  vulture = ProspectorVulture(found_files)
79
89
  vulture.scavenge()
80
90
  return [message for message in vulture.get_messages() if message.code not in self.ignore_codes]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: prospector
3
- Version: 1.10.0
3
+ Version: 1.13.2
4
4
  Summary: Prospector is a tool to analyse Python code by aggregating the result of other tools.
5
5
  Home-page: http://prospector.readthedocs.io
6
6
  License: GPLv2+
@@ -9,7 +9,7 @@ Author: Carl Crowder
9
9
  Author-email: git@carlcrowder.com
10
10
  Maintainer: Carl Crowder
11
11
  Maintainer-email: git@carlcrowder.com
12
- Requires-Python: >=3.7.2,<4.0
12
+ Requires-Python: >=3.9,<4.0
13
13
  Classifier: Development Status :: 5 - Production/Stable
14
14
  Classifier: Environment :: Console
15
15
  Classifier: Intended Audience :: Developers
@@ -17,13 +17,12 @@ Classifier: License :: OSI Approved :: GNU General Public License v2 or later (G
17
17
  Classifier: License :: Other/Proprietary License
18
18
  Classifier: Operating System :: Unix
19
19
  Classifier: Programming Language :: Python :: 3
20
- Classifier: Programming Language :: Python :: 3.8
21
20
  Classifier: Programming Language :: Python :: 3.9
22
21
  Classifier: Programming Language :: Python :: 3.10
23
22
  Classifier: Programming Language :: Python :: 3.10
24
23
  Classifier: Programming Language :: Python :: 3.11
25
- Classifier: Programming Language :: Python :: 3.7
26
- Classifier: Programming Language :: Python :: 3.8
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Programming Language :: Python :: 3.13
27
26
  Classifier: Programming Language :: Python :: 3.9
28
27
  Classifier: Topic :: Software Development :: Quality Assurance
29
28
  Provides-Extra: with_bandit
@@ -31,27 +30,27 @@ Provides-Extra: with_everything
31
30
  Provides-Extra: with_mypy
32
31
  Provides-Extra: with_pyright
33
32
  Provides-Extra: with_pyroma
33
+ Provides-Extra: with_ruff
34
34
  Provides-Extra: with_vulture
35
35
  Requires-Dist: GitPython (>=3.1.27,<4.0.0)
36
36
  Requires-Dist: PyYAML
37
37
  Requires-Dist: bandit (>=1.5.1); extra == "with_bandit" or extra == "with_everything"
38
38
  Requires-Dist: dodgy (>=0.2.1,<0.3.0)
39
- Requires-Dist: flake8 (<6.0.0)
40
39
  Requires-Dist: mccabe (>=0.7.0,<0.8.0)
41
40
  Requires-Dist: mypy (>=0.600); extra == "with_mypy" or extra == "with_everything"
42
41
  Requires-Dist: packaging
43
42
  Requires-Dist: pep8-naming (>=0.3.3,<=0.10.0)
44
43
  Requires-Dist: pycodestyle (>=2.9.0)
45
44
  Requires-Dist: pydocstyle (>=2.0.0)
46
- Requires-Dist: pyflakes (>=2.2.0,<3)
47
- Requires-Dist: pylint (>=2.8.3)
45
+ Requires-Dist: pyflakes (>=2.2.0)
46
+ Requires-Dist: pylint (>=3.0)
48
47
  Requires-Dist: pylint-celery (==0.3)
49
- Requires-Dist: pylint-django (>=2.5,<2.6)
48
+ Requires-Dist: pylint-django (>=2.6.1)
50
49
  Requires-Dist: pylint-flask (==0.6)
51
- Requires-Dist: pylint-plugin-utils (>=0.7,<0.8)
52
50
  Requires-Dist: pyright (>=1.1.3); extra == "with_pyright" or extra == "with_everything"
53
51
  Requires-Dist: pyroma (>=2.4); extra == "with_pyroma" or extra == "with_everything"
54
- Requires-Dist: requirements-detector (>=1.2.0)
52
+ Requires-Dist: requirements-detector (>=1.3.2)
53
+ Requires-Dist: ruff; extra == "with_ruff" or extra == "with_everything"
55
54
  Requires-Dist: setoptconf-tmp (>=0.3.1,<0.4.0)
56
55
  Requires-Dist: toml (>=0.10.2,<0.11.0)
57
56
  Requires-Dist: vulture (>=1.5); extra == "with_vulture" or extra == "with_everything"
@@ -208,7 +207,7 @@ text to your repositories' ``.pre-commit-config.yaml``::
208
207
 
209
208
  repos:
210
209
  - repo: https://github.com/PyCQA/prospector
211
- rev: 1.7.5 # The version of Prospector to use, if not 'master' for latest
210
+ rev: 1.10.0 # The version of Prospector to use, if not 'master' for latest
212
211
  hooks:
213
212
  - id: prospector
214
213
 
@@ -217,7 +216,7 @@ them to the hook configuration like so::
217
216
 
218
217
  repos:
219
218
  - repo: https://github.com/PyCQA/prospector
220
- rev: 1.7.5
219
+ rev: 1.10.0
221
220
  hooks:
222
221
  - id: prospector
223
222
  additional_dependencies:
@@ -249,7 +248,7 @@ added as command line arguments to the hook. For example::
249
248
 
250
249
  repos:
251
250
  - repo: https://github.com/PyCQA/prospector
252
- rev: 1.7.5
251
+ rev: 1.10.0
253
252
  hooks:
254
253
  - id: prospector
255
254
  additional_dependencies:
@@ -0,0 +1,71 @@
1
+ prospector/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ prospector/__main__.py,sha256=-gdHYZxwq_P8er7HuZEBImY0pwaFq8uIa78dQdJsTTQ,71
3
+ prospector/autodetect.py,sha256=Ok8S6jpDiGyhQlnRCMWpsLpSAIXWxA-NQphQuPaOm6o,3112
4
+ prospector/blender.py,sha256=ldQSkfoEKv6pd72B9YCYdapeGUzgfhGzieAu7To3l6Y,4926
5
+ prospector/blender_combinations.yaml,sha256=yN7BOUCDomDZVRZzYxsRdxQPLpzxm9TDhv18B_GdLPU,6551
6
+ prospector/compat.py,sha256=p_2BOebzUcKbUAd7mW8rn6tIc10R96gJuZS71QI0XY4,360
7
+ prospector/config/__init__.py,sha256=4nYshBncKUvZrwNKmp2bQ2mQ8uRS7GU20xPbiC-nJ9g,14793
8
+ prospector/config/configuration.py,sha256=sNYR5Jc3P7tfIDXQoDMrOX4i2Yde0o9bc21ZXZNn6rw,14046
9
+ prospector/config/datatype.py,sha256=u2i3YxtFKXkeGKzrYnc8koI-Xq-Owl74e_XveNhFY8Y,658
10
+ prospector/encoding.py,sha256=67sbqzcUoQqi3PRm_P3GNGwcL1N56RZ3T_YHmSrICEE,1549
11
+ prospector/exceptions.py,sha256=3P58RNF7j1n4CUIZ8VM5BVhB4Q6UtVs-dQRG8TRCZ7o,1248
12
+ prospector/finder.py,sha256=-gqGVEv6c6FEyKWZIcQ7FquSlVKvpVWsJK9-HkTeg3c,4778
13
+ prospector/formatters/__init__.py,sha256=ixMDeM27mmaLBxHmcRYoC1tPPi17SBXS91Rc2dMv30s,467
14
+ prospector/formatters/base.py,sha256=SMRvrX1xAQ1aaM8S-wPSH7cbs-x8QEXmLW0PeSf6PIg,1436
15
+ prospector/formatters/base_summary.py,sha256=C2O6XAU4l-rOHL1q4rA56jO9sU7Sf0sHRvqgiY6PQgw,1410
16
+ prospector/formatters/emacs.py,sha256=FwMqdDxCKA51B76ORuSJE1E2xy-glNpORIzAQaw7LUM,807
17
+ prospector/formatters/grouped.py,sha256=-vD8I3unoO0FBISoUPHZPCa0p-btWMvt1D_UxzmcGDA,1357
18
+ prospector/formatters/json.py,sha256=_DbZ_Eb0fmZf6qZMXCU__QRXv_awkBisZ-jvGfOr4aw,1000
19
+ prospector/formatters/pylint.py,sha256=WAdD9tMYkk4BWfhoqJJBRc2d3xxQ0bJdQXOZU0ZzYTE,2871
20
+ prospector/formatters/text.py,sha256=5czha8YfdJ9SD6vWLHE85LgB3-d0lHOsxpYhtokRmTU,1611
21
+ prospector/formatters/vscode.py,sha256=ffP-JmrgZhhdirTj1ldV5fG10hdDiHjRfekSqQpQmx0,1643
22
+ prospector/formatters/xunit.py,sha256=e5ObAWSLm-ekvWs8xsi-OaIL2yoYedlxuJdUhLZ8gkk,2464
23
+ prospector/formatters/yaml.py,sha256=0RAL5BaaL9A0DfWZ-bdpK1mwgr8zJ_ULVwlnSXVPlDU,684
24
+ prospector/message.py,sha256=ty_e5T7fpZcZb69sAUIgvV-9qHuAx6-Nkq3bP6IVAqw,3279
25
+ prospector/pathutils.py,sha256=CyZIj4WXGill8OfnqRvcVqZYX0lzL3QcIxpkxCz-dkE,1219
26
+ prospector/postfilter.py,sha256=rJ37Zb-dqzKSwpzgpePZR-AIEgRdOTc2C5LbxGNDVm0,2225
27
+ prospector/profiles/__init__.py,sha256=q9zPLVEwo7qoouYFrmENsmByFrKKkr27Dd_Wo9btTJI,683
28
+ prospector/profiles/exceptions.py,sha256=MDky4KXVwfOlW1yCbyp8Y07D8Kfz76jL3z-8T3WQIFI,1062
29
+ prospector/profiles/profile.py,sha256=U8vDdyfka0_Ht9cYT2i_c-xbMcktSpS1h53cU7tGerk,17828
30
+ prospector/profiles/profiles/default.yaml,sha256=tMy-G49ZdV7gkfBoN2ngtIWha3n7JVr_rEeNkLzpKsk,100
31
+ prospector/profiles/profiles/doc_warnings.yaml,sha256=K_cBhUeKnSvOCwgwXE2tMZ-Fr5cJovC1XSholWglzN4,48
32
+ prospector/profiles/profiles/flake8.yaml,sha256=wC-TJYuVobo9zPm4Yc_Ocd4Wwfemx0IufmAnfiuKkHk,156
33
+ prospector/profiles/profiles/full_pep8.yaml,sha256=Y01UuDKsk-3akQGIM05aDjGM99x91CXOTeLcYPed3po,873
34
+ prospector/profiles/profiles/member_warnings.yaml,sha256=RpDCUcg6Nki77T5Ov2s1QlalOLX8soPtp_8CK20xbic,82
35
+ prospector/profiles/profiles/no_doc_warnings.yaml,sha256=6Q_g5xNKJlEhM6PvtE1Wb6Jlq_gq_HKkIGfgqXTozqc,271
36
+ prospector/profiles/profiles/no_member_warnings.yaml,sha256=1ImTwpubSHXEwq76aO3jVSE7VvjzZG6BGudAv9reccw,83
37
+ prospector/profiles/profiles/no_pep8.yaml,sha256=cnjvmO-0kcul-URYJv-kJsaob2Zc4bCUJLiYiIVzN84,348
38
+ prospector/profiles/profiles/no_test_warnings.yaml,sha256=vDlRgnOr1YhEAwGW2fmTydHYq10k9nrMyQdM-K6H9EA,175
39
+ prospector/profiles/profiles/strictness_high.yaml,sha256=4IHE07_JMjZdAz5w_mRFt-kP1sTbQuz5rrPJ3InGm2I,818
40
+ prospector/profiles/profiles/strictness_low.yaml,sha256=QONar05NOI_cidCoRASmDFzd7CSk_JC-KVjwDzcPU_8,1066
41
+ prospector/profiles/profiles/strictness_medium.yaml,sha256=z8LNJTbACa2L24TCNVfkGA-PUvnZgzJk7yDiDFRj8eo,1836
42
+ prospector/profiles/profiles/strictness_none.yaml,sha256=_Yf-eEl4cVXw6ePqx3V4mvG80JksH9ggkUqbuAdR5iI,151
43
+ prospector/profiles/profiles/strictness_veryhigh.yaml,sha256=m93J1OzGCRVTWrIQbzhYJux9BCC7amdp5e9ePxIkbDY,594
44
+ prospector/profiles/profiles/strictness_verylow.yaml,sha256=YxZowcBtA3tAaHJGz2htTdAJ-AXmlHB-o4zEYKPRfJg,833
45
+ prospector/profiles/profiles/test_warnings.yaml,sha256=arUcV9MnqiZJEHURH9bVRSYDhYUegNc-ltFYe_yQW44,23
46
+ prospector/run.py,sha256=hjNyzY-wyedGwJspT80jCz4usk-HqL6FmqDcinASJZA,8403
47
+ prospector/suppression.py,sha256=5VPSvw1ECIR1_4spf0Q2jUx04GygEoptA4LDFaErYVU,4954
48
+ prospector/tools/__init__.py,sha256=9tDmxL_kn5jmAACeSi1jtSvT-9tI468Ccn1Up2wUFi0,2956
49
+ prospector/tools/bandit/__init__.py,sha256=oQZANkiQh3MI2HjtLNXbW-yWrtzlbdq2oaGl2_7B4dM,2711
50
+ prospector/tools/base.py,sha256=T1F-vq4rNcaToA4fXjZmcozkABpeiz0odFAMVMEJM1w,1838
51
+ prospector/tools/dodgy/__init__.py,sha256=howLCjFEheW_6ZoyQ15gLbiNNNUr0Pm2qNpLg3kleFY,1648
52
+ prospector/tools/exceptions.py,sha256=Q-u4n6YzZuoMu17XkeKac1o1gBY36JK4MnvWaYrVYL0,170
53
+ prospector/tools/mccabe/__init__.py,sha256=80-aYPqKCREeBqxiIUgsDvxc_GqYxHb5R0JduKHPRaE,3277
54
+ prospector/tools/mypy/__init__.py,sha256=rv4FVOT0ry7E3DlInjKO1_fa01T7IyrxxC3-weL4RuQ,3504
55
+ prospector/tools/profile_validator/__init__.py,sha256=bAkVG-fKtm3WaEv-We36wqzvtqWv4s06Z7YnRVG7UQ4,8326
56
+ prospector/tools/pycodestyle/__init__.py,sha256=uMpUxqsPsryEsfyfGxpLzwoWUjIvfxIQke4Xvkfbi9A,5970
57
+ prospector/tools/pydocstyle/__init__.py,sha256=WB-AT-c1FeUUUWATUzJbBLeREtu-lxT03bChh4nablo,2776
58
+ prospector/tools/pyflakes/__init__.py,sha256=53NQFODU416KO991NxW14gChjagbSAhhfErx1ll7VUQ,5631
59
+ prospector/tools/pylint/__init__.py,sha256=WoI23QXmGlumgZMRg1-tQJ8Tpzl9_KpLUQIKlb7vEkE,11108
60
+ prospector/tools/pylint/collector.py,sha256=_PEV_8nV77_87m8rA2Td4WOqO9F2UaIQ4Bb_aUv_WQg,1377
61
+ prospector/tools/pylint/linter.py,sha256=YQ9SOna4WjbbauqSgUio6Ss8zN08PCr3aKdK9rMi7Ag,2143
62
+ prospector/tools/pyright/__init__.py,sha256=USqauZofh-8ZSKGwXRXoaM2ItzfSFo2nGwPtLGEWICU,3346
63
+ prospector/tools/pyroma/__init__.py,sha256=GPQRJZfbs_SI0RBTyySz-4SIuM__YoLfXAm7uYVXAS8,3151
64
+ prospector/tools/ruff/__init__.py,sha256=HRj2S-I45DCg3y4T6035PvHyRutTPU9Boeh3IWU9_pw,3300
65
+ prospector/tools/utils.py,sha256=4wj7Lz-mYs6QIdvP-kCLlXs-ZRSkrwLpSKn9xHvDpgw,1585
66
+ prospector/tools/vulture/__init__.py,sha256=eaTh4X5onNlBMuz1x0rmcRn7x5XDVDgqftjIEd47eWI,3583
67
+ prospector-1.13.2.dist-info/entry_points.txt,sha256=SxvCGt8MJTEZefHAvwnUc6jDetgCaaYY1Zpifuk8tqU,50
68
+ prospector-1.13.2.dist-info/LICENSE,sha256=WoTRadDy8VbcIKoVzl5Q1QipuD_cexAf3ul4MaVLttc,18044
69
+ prospector-1.13.2.dist-info/WHEEL,sha256=gSF7fibx4crkLz_A-IKR6kcuq0jJ64KNCkG8_bcaEao,88
70
+ prospector-1.13.2.dist-info/METADATA,sha256=M45kwECENnOkBYWyx6v5887c_iujb4Mu554svWtnsbU,9962
71
+ prospector-1.13.2.dist-info/RECORD,,
README.rst DELETED
@@ -1,208 +0,0 @@
1
- prospector
2
- ==========
3
-
4
- .. image:: https://img.shields.io/pypi/v/prospector.svg
5
- :target: https://pypi.python.org/pypi/prospector
6
- :alt: Latest Version of Prospector
7
- .. image:: https://github.com/PyCQA/prospector/actions/workflows/tests.yml/badge.svg
8
- :target: https://github.com/PyCQA/prospector/actions/workflows/tests.yml
9
- :alt: Build Status
10
- .. image:: https://img.shields.io/coveralls/PyCQA/prospector.svg?style=flat
11
- :target: https://coveralls.io/r/PyCQA/prospector
12
- :alt: Test Coverage
13
- .. image:: https://readthedocs.org/projects/prospector/badge/?version=latest
14
- :target: https://prospector.readthedocs.io/
15
- :alt: Documentation
16
-
17
-
18
- About
19
- -----
20
-
21
- Prospector is a tool to analyse Python code and output information about
22
- errors, potential problems, convention violations and complexity.
23
-
24
- It brings together the functionality of other Python analysis tools such as
25
- `Pylint <https://docs.pylint.org/>`_,
26
- `pycodestyle <https://pycodestyle.pycqa.org/>`_,
27
- and `McCabe complexity <https://pypi.python.org/pypi/mccabe>`_.
28
- See the `Supported Tools <https://prospector.readthedocs.io/en/latest/supported_tools.html>`_
29
- documentation section for a complete list.
30
-
31
- The primary aim of Prospector is to be useful 'out of the box'. A common complaint of other
32
- Python analysis tools is that it takes a long time to filter through which errors are relevant
33
- or interesting to your own coding style. Prospector provides some default profiles, which
34
- hopefully will provide a good starting point and will be useful straight away, and adapts
35
- the output depending on the libraries your project uses.
36
-
37
- Installation
38
- ------------
39
-
40
- Prospector can be installed from PyPI using ``pip`` by running the following command::
41
-
42
- pip install prospector
43
-
44
- Optional dependencies for Prospector, such as ``pyroma`` can also be installed by running::
45
-
46
- pip install prospector[with_pyroma]
47
-
48
- Some shells (such as ``Zsh``, the default shell of macOS Catalina) require brackets to be escaped::
49
-
50
- pip install prospector\[with_pyroma\]
51
-
52
- For a list of all of the optional dependencies, see the optional extras section on the ReadTheDocs
53
- page on `Supported Tools Extras <https://prospector.readthedocs.io/en/latest/supported_tools.html#optional-extras>`_.
54
-
55
- For local development, `poetry <https://python-poetry.org/>`_ is used. Check out the code, then run::
56
-
57
- poetry install
58
-
59
- And for extras::
60
-
61
- poetry install -E with_everything
62
-
63
- For more detailed information on installing the tool, see the
64
- `installation section <https://prospector.readthedocs.io/en/latest/#installation>`_ of the tool's main page
65
- on ReadTheDocs.
66
-
67
- Documentation
68
- -------------
69
-
70
- Full `documentation is available at ReadTheDocs <https://prospector.readthedocs.io>`_.
71
-
72
- Usage
73
- -----
74
-
75
- Simply run prospector from the root of your project::
76
-
77
- prospector
78
-
79
- This will output a list of messages pointing out potential problems or errors, for example::
80
-
81
- prospector.tools.base (prospector/tools/base.py):
82
- L5:0 ToolBase: pylint - R0922
83
- Abstract class is only referenced 1 times
84
-
85
- Options
86
- ```````
87
-
88
- Run ``prospector --help`` for a full list of options and their effects.
89
-
90
- Output Format
91
- ~~~~~~~~~~~~~
92
-
93
- The default output format of ``prospector`` is designed to be human readable. For parsing
94
- (for example, for reporting), you can use the ``--output-format json`` flag to get JSON-formatted
95
- output.
96
-
97
- Profiles
98
- ~~~~~~~~
99
-
100
- Prospector is configurable using "profiles". These are composable YAML files with directives to
101
- disable or enable tools or messages. For more information, read
102
- `the documentation about profiles <https://prospector.readthedocs.io/en/latest/profiles.html>`_.
103
-
104
- If your code uses frameworks and libraries
105
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
106
-
107
- Often tools such as pylint find errors in code which is not an error, for example due to attributes of classes being
108
- created at run time by a library or framework used by your project.
109
- For example, by default, pylint will generate an error for Django models when accessing ``objects``, as the
110
- ``objects`` attribute is not part of the ``Model`` class definition.
111
-
112
- Prospector mitigates this by providing an understanding of these frameworks to the underlying tools.
113
-
114
- Prospector will try to intuit which libraries your project uses by
115
- `detecting dependencies <https://github.com/landscapeio/requirements-detector>`_ and automatically turning on
116
- support for the requisite libraries. You can see which adaptors were run in the metadata section of the report.
117
-
118
- If Prospector does not correctly detect your project's dependencies, you can specify them manually from the commandline::
119
-
120
- prospector --uses django celery
121
-
122
- Additionally, if Prospector is automatically detecting a library that you do not in fact use, you can turn
123
- off autodetection completely::
124
-
125
- prospector --no-autodetect
126
-
127
- Note that as far as possible, these adaptors have been written as plugins or augmentations for the underlying
128
- tools so that they can be used without requiring Prospector. For example, the Django support is available as a pylint plugin.
129
-
130
- Strictness
131
- ~~~~~~~~~~
132
-
133
- Prospector has a configurable 'strictness' level which will determine how harshly it searches for errors::
134
-
135
- prospector --strictness high
136
-
137
- Possible values are ``verylow``, ``low``, ``medium``, ``high``, ``veryhigh``.
138
-
139
- Prospector does not include documentation warnings by default, but you can turn
140
- this on using the ``--doc-warnings`` flag.
141
-
142
- pre-commit
143
- ----------
144
-
145
- If you'd like Prospector to be run automatically when making changes to files in your Git
146
- repository, you can install `pre-commit <https://pre-commit.com/>`_ and add the following
147
- text to your repositories' ``.pre-commit-config.yaml``::
148
-
149
- repos:
150
- - repo: https://github.com/PyCQA/prospector
151
- rev: 1.7.5 # The version of Prospector to use, if not 'master' for latest
152
- hooks:
153
- - id: prospector
154
-
155
- This only installs base prospector - if you also use optional tools, for example bandit and/or mypy, then you can add
156
- them to the hook configuration like so::
157
-
158
- repos:
159
- - repo: https://github.com/PyCQA/prospector
160
- rev: 1.7.5
161
- hooks:
162
- - id: prospector
163
- additional_dependencies:
164
- - ".[with_mypy,with_bandit]"
165
- - args: [
166
- '--with-tool=mypy',
167
- '--with-tool=bandit',
168
- ]
169
-
170
- Additional dependencies can be `individually configured <https://prospector.landscape.io/en/master/profiles.html#individual-configuration-options>`_ in your `prospector.yml` file ::
171
-
172
- # https://bandit.readthedocs.io/en/latest/config.html
173
- bandit:
174
- options:
175
- skips:
176
- - B201
177
- - B601
178
- - B610
179
- - B611
180
- - B703
181
-
182
- # https://mypy.readthedocs.io/en/stable/command_line.html
183
- mypy:
184
- options:
185
- ignore-missing-imports: true
186
-
187
- For prospector options which affect display only - those which are not configurable using a profile - these can be
188
- added as command line arguments to the hook. For example::
189
-
190
- repos:
191
- - repo: https://github.com/PyCQA/prospector
192
- rev: 1.7.5
193
- hooks:
194
- - id: prospector
195
- additional_dependencies:
196
- - ".[with_mypy,with_bandit]"
197
- args:
198
- - --with-tool=mypy
199
- - --with-tool=bandit
200
- - --summary-only
201
- - --zero-exit
202
-
203
-
204
-
205
- License
206
- -------
207
-
208
- Prospector is available under the GPLv2 License.