Python: Tag quality queries with quality and sub category. #19812
Merged
tausbn merged 13 commits intogithub:mainfrom Jun 19, 2025
Merged
Python: Tag quality queries with quality and sub category. #19812tausbn merged 13 commits intogithub:mainfrom
quality and sub category. #19812tausbn merged 13 commits intogithub:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
Adds the quality tag (with top-level categories and subcategories) to existing Python queries and updates the Python code-quality suite.
- Standardize metadata: add
qualitytag and assign appropriate sub-category tags across many Python QL queries - Document change: add a change-note entry for the new quality-tag convention
- Update tests: expand the Python code-quality suite’s expected query list
Reviewed Changes
Copilot reviewed 94 out of 94 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| python/ql/src/change-notes/2025-06-18-quality-query-metadata.md | Add entry describing the new quality category and sub-category tagging convention |
| python/ql/src/**/*.ql | Add quality tag and assign one or more sub-category tags (reliability, maintainability, correctness, etc.) to each Python query |
| python/ql/integration-tests/query-suite/python-code-quality.qls.expected | Update the expected list of queries included in the python-code-quality test suite |
Comments suppressed due to low confidence (2)
python/ql/integration-tests/query-suite/python-code-quality.qls.expected:1
- Paths in this expected list are missing the
python/prefix (python/ql/src/...) and won’t match the actual file locations; please restore the full relative path.
ql/src/Classes/ConflictingAttributesInBaseClasses.ql
tausbn
requested changes
Jun 18, 2025
Contributor
tausbn
left a comment
There was a problem hiding this comment.
I've made a few comments/suggestions here and there, but overall this looks good to me. 👍
python/ql/src/Functions/IncorrectlySpecifiedOverriddenMethod.ql
Outdated
Show resolved
Hide resolved
| * maintainability | ||
| * @tags quality | ||
| * reliability | ||
| * correctness |
Contributor
There was a problem hiding this comment.
Could add performance here.
80d2a03 to
3e891bf
Compare
Excluded for now for uncertainty: incomplete ordering, import deprecated module
Excluded for now: unnecassary-delete; since the pattern is often intentional to break reference cycles, which the query doesn't account for; so uncertain about its claim of high precision
Excluded queries that are python 2 specific; as well as the cyclic import queries
b9b0e51 to
e67f057
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updated tags for high and very high precision quality queries, using the query metadata guide. It is intended that all of these queries will now be in the quality suite.
A few queries were excluded from this process:
The following queries are specific to python 2; we probably don't need them in the quality suite and could deprecate them at some point:
py/old-style-octal-literalpy/truncated-divisionpy/inconsistent-equalitypy/property-in-old-style-classpy/slots-in-old-style-classpy/super-in-old-stylepy/raises-tuplepy/unguarded-next-in-generatorpy/use-of-applypy/use-of-inputpy/deprecated-slice-methodpy/leaking-list-comprehensionThe following queries I was uncertain about, so I have excluded for now:
py/incomplete-ordering- While this query makes sense for python 3, its current implementation is specific to python 2; since it checks for all four comparison methods being defined, whereas in python 3 only__lt__and__le__need to be defined. Thus, as is, this query may have more FPs and a lower precision than itsprecision: hightag suggests.py/import-deprecated-module- This query includes a list of deprecated modules (and suggested replacements) that is very old; so uncertain of the utility of including it in the quality suite without updating it.py/unnecessary-delete- I am uncertain about the precision/FP rate of this query, despite itsprecision: hightag - since it is relatively common to usedelto break reference cycles, which this query doesn't appear to account for.py/cyclic-importandpy/unsafe-cyclic-import- These queries were discussed at some point in a team meeting as queries that we are uncertain about maintaining (in the context of modernizing quality queries), due to its complexity and difficulty to distinguish cases in which the pattern is intentional and done carefully and correctly, from true positives.