| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,3 +35,5 @@ jobs: | |||
| 35 | 35 | run: tox -e mypy | |
| 36 | 36 | - name: Run isort import order checker (https://pycqa.github.io/isort/) | |
| 37 | 37 | run: tox -e isort -- --check | |
| 38 | + - name: Run pylint Python code static checker (https://www.pylint.org/) | ||
| 39 | + run: tox -e pylint | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,32 @@ | |||
| 1 | + name: pre_commit | ||
| 2 | + | ||
| 3 | + on: | ||
| 4 | + push: | ||
| 5 | + branches: | ||
| 6 | + - main | ||
| 7 | + paths: | ||
| 8 | + .github/workflows/pre_commit.yml | ||
| 9 | + .pre-commit-config.yaml | ||
| 10 | + pull_request: | ||
| 11 | + branches: | ||
| 12 | + - main | ||
| 13 | + - master | ||
| 14 | + paths: | ||
| 15 | + - .github/workflows/pre_commit.yml | ||
| 16 | + - .pre-commit-config.yaml | ||
| 17 | + | ||
| 18 | + env: | ||
| 19 | + PY_COLORS: 1 | ||
| 20 | + | ||
| 21 | + jobs: | ||
| 22 | + | ||
| 23 | + pre_commit: | ||
| 24 | + runs-on: ubuntu-latest | ||
| 25 | + steps: | ||
| 26 | + - uses: actions/checkout@v2 | ||
| 27 | + - uses: actions/setup-python@v2 | ||
| 28 | + - run: pip install --upgrade -r requirements.txt -r requirements-lint.txt pre-commit | ||
| 29 | + - name: Run pre-commit install | ||
| 30 | + run: pre-commit install | ||
| 31 | + - name: pre-commit run all-files | ||
| 32 | + run: pre-commit run --all-files | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,10 +20,20 @@ repos: | |||
| 20 | 20 | rev: 5.9.3 | |
| 21 | 21 | hooks: | |
| 22 | 22 | - id: isort | |
| 23 | + - repo: https://github.com/pycqa/pylint | ||
| 24 | + rev: v2.12.2 | ||
| 25 | + hooks: | ||
| 26 | + - id: pylint | ||
| 27 | + additional_dependencies: | ||
| 28 | + - argcomplete==1.12.3 | ||
| 29 | + - requests==2.26.0 | ||
| 30 | + - requests-toolbelt==0.9.1 | ||
| 31 | + files: 'gitlab/' | ||
| 23 | 32 | - repo: https://github.com/pre-commit/mirrors-mypy | |
| 24 | 33 | rev: v0.910 | |
| 25 | 34 | hooks: | |
| 26 | 35 | - id: mypy | |
| 36 | + args: [] | ||
| 27 | 37 | additional_dependencies: | |
| 28 | 38 | - types-PyYAML==6.0.1 | |
| 29 | 39 | - types-requests==2.26.1 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -140,7 +140,7 @@ def set_approvers( | |||
| 140 | 140 | approval_rules: ProjectMergeRequestApprovalRuleManager = ( | |
| 141 | 141 | self._parent.approval_rules | |
| 142 | 142 | ) | |
| 143 | - """ update any existing approval rule matching the name""" | ||
| 143 | + # update any existing approval rule matching the name | ||
| 144 | 144 | existing_approval_rules = approval_rules.list() | |
| 145 | 145 | for ar in existing_approval_rules: | |
| 146 | 146 | if ar.name == approval_rule_name: | |
@@ -149,7 +149,7 @@ def set_approvers( | |||
| 149 | 149 | ar.group_ids = data["group_ids"] | |
| 150 | 150 | ar.save() | |
| 151 | 151 | return ar | |
| 152 | - """ if there was no rule matching the rule name, create a new one""" | ||
| 152 | + # if there was no rule matching the rule name, create a new one | ||
| 153 | 153 | return approval_rules.create(data=data) | |
| 154 | 154 | ||
| 155 | 155 | ||
@@ -171,13 +171,13 @@ def save(self, **kwargs: Any) -> None: | |||
| 171 | 171 | GitlabAuthenticationError: If authentication is not correct | |
| 172 | 172 | GitlabUpdateError: If the server cannot perform the request | |
| 173 | 173 | """ | |
| 174 | - # There is a mismatch between the name of our id attribute and the put REST API name for the | ||
| 175 | - # project_id, so we override it here. | ||
| 174 | + # There is a mismatch between the name of our id attribute and the put | ||
| 175 | + # REST API name for the project_id, so we override it here. | ||
| 176 | 176 | self.approval_rule_id = self.id | |
| 177 | 177 | self.merge_request_iid = self._parent_attrs["mr_iid"] | |
| 178 | 178 | self.id = self._parent_attrs["project_id"] | |
| 179 | - # save will update self.id with the result from the server, so no need to overwrite with | ||
| 180 | - # what it was before we overwrote it.""" | ||
| 179 | + # save will update self.id with the result from the server, so no need | ||
| 180 | + # to overwrite with what it was before we overwrote it. | ||
| 181 | 181 | SaveMixin.save(self, **kwargs) | |
| 182 | 182 | ||
| 183 | 183 | ||
@@ -198,8 +198,9 @@ class ProjectMergeRequestApprovalRuleManager( | |||
| 198 | 198 | ), | |
| 199 | 199 | optional=("user_ids", "group_ids"), | |
| 200 | 200 | ) | |
| 201 | - # Important: When approval_project_rule_id is set, the name, users and groups of | ||
| 202 | - # project-level rule will be copied. The approvals_required specified will be used. """ | ||
| 201 | + # Important: When approval_project_rule_id is set, the name, users and | ||
| 202 | + # groups of project-level rule will be copied. The approvals_required | ||
| 203 | + # specified will be used. | ||
| 203 | 204 | _create_attrs = RequiredOptional( | |
| 204 | 205 | required=("id", "merge_request_iid", "name", "approvals_required"), | |
| 205 | 206 | optional=("approval_project_rule_id", "user_ids", "group_ids"), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -597,10 +597,12 @@ def artifact( | |||
| 597 | 597 | chunk_size: int = 1024, | |
| 598 | 598 | **kwargs: Any, | |
| 599 | 599 | ) -> Optional[bytes]: | |
| 600 | - """Download a single artifact file from a specific tag or branch from within the job’s artifacts archive. | ||
| 600 | + """Download a single artifact file from a specific tag or branch from | ||
| 601 | + within the job’s artifacts archive. | ||
| 601 | 602 | ||
| 602 | 603 | Args: | |
| 603 | - ref_name: Branch or tag name in repository. HEAD or SHA references are not supported. | ||
| 604 | + ref_name: Branch or tag name in repository. HEAD or SHA references | ||
| 605 | + are not supported. | ||
| 604 | 606 | artifact_path: Path to a file inside the artifacts archive. | |
| 605 | 607 | job: The name of the job. | |
| 606 | 608 | streamed: If True the data will be processed by chunks of | |
@@ -619,7 +621,10 @@ def artifact( | |||
| 619 | 621 | The artifacts if `streamed` is False, None otherwise. | |
| 620 | 622 | """ | |
| 621 | 623 | ||
| 622 | - path = f"/projects/{self.get_id()}/jobs/artifacts/{ref_name}/raw/{artifact_path}?job={job}" | ||
| 624 | + path = ( | ||
| 625 | + f"/projects/{self.get_id()}/jobs/artifacts/{ref_name}/raw/" | ||
| 626 | + f"{artifact_path}?job={job}" | ||
| 627 | + ) | ||
| 623 | 628 | result = self.manager.gitlab.http_get( | |
| 624 | 629 | path, streamed=streamed, raw=True, **kwargs | |
| 625 | 630 | ) | |
@@ -857,7 +862,8 @@ def import_bitbucket_server( | |||
| 857 | 862 | ||
| 858 | 863 | .. note:: | |
| 859 | 864 | This request may take longer than most other API requests. | |
| 860 | - So this method will specify a 60 second default timeout if none is specified. | ||
| 865 | + So this method will specify a 60 second default timeout if none is | ||
| 866 | + specified. | ||
| 861 | 867 | A timeout can be specified via kwargs to override this functionality. | |
| 862 | 868 | ||
| 863 | 869 | Args: | |
@@ -945,7 +951,8 @@ def import_github( | |||
| 945 | 951 | ||
| 946 | 952 | .. note:: | |
| 947 | 953 | This request may take longer than most other API requests. | |
| 948 | - So this method will specify a 60 second default timeout if none is specified. | ||
| 954 | + So this method will specify a 60 second default timeout if none is | ||
| 955 | + specified. | ||
| 949 | 956 | A timeout can be specified via kwargs to override this functionality. | |
| 950 | 957 | ||
| 951 | 958 | Args: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,3 +41,50 @@ branch = "main" | |||
| 41 | 41 | version_variable = "gitlab/__version__.py:__version__" | |
| 42 | 42 | commit_subject = "chore: release v{version}" | |
| 43 | 43 | commit_message = "" | |
| 44 | + | ||
| 45 | + [tool.pylint.messages_control] | ||
| 46 | + max-line-length = 88 | ||
| 47 | + # TODO(jlvilla): Work on removing these disables over time. | ||
| 48 | + disable = [ | ||
| 49 | + "arguments-differ", | ||
| 50 | + "arguments-renamed", | ||
| 51 | + "attribute-defined-outside-init", | ||
| 52 | + "broad-except", | ||
| 53 | + "consider-using-f-string", | ||
| 54 | + "consider-using-generator", | ||
| 55 | + "consider-using-sys-exit", | ||
| 56 | + "cyclic-import", | ||
| 57 | + "duplicate-code", | ||
| 58 | + "expression-not-assigned", | ||
| 59 | + "fixme", | ||
| 60 | + "implicit-str-concat", | ||
| 61 | + "import-outside-toplevel", | ||
| 62 | + "invalid-name", | ||
| 63 | + "missing-class-docstring", | ||
| 64 | + "missing-function-docstring", | ||
| 65 | + "missing-module-docstring", | ||
| 66 | + "no-else-return", | ||
| 67 | + "no-self-use", | ||
| 68 | + "protected-access", | ||
| 69 | + "raise-missing-from", | ||
| 70 | + "redefined-builtin", | ||
| 71 | + "redefined-outer-name", | ||
| 72 | + "signature-differs", | ||
| 73 | + "super-with-arguments", | ||
| 74 | + "too-few-public-methods", | ||
| 75 | + "too-many-ancestors", | ||
| 76 | + "too-many-arguments", | ||
| 77 | + "too-many-branches", | ||
| 78 | + "too-many-instance-attributes", | ||
| 79 | + "too-many-lines", | ||
| 80 | + "too-many-locals", | ||
| 81 | + "too-many-statements", | ||
| 82 | + "unexpected-keyword-arg", | ||
| 83 | + "unnecessary-pass", | ||
| 84 | + "unspecified-encoding", | ||
| 85 | + "unsubscriptable-object", | ||
| 86 | + "unused-argument", | ||
| 87 | + "useless-import-alias", | ||
| 88 | + "useless-object-inheritance", | ||
| 89 | + | ||
| 90 | + ] | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,8 +1,10 @@ | |||
| 1 | + argcomplete==1.12.3 | ||
| 1 | 2 | black==21.12b0 | |
| 2 | 3 | flake8==4.0.1 | |
| 3 | 4 | isort==5.10.1 | |
| 4 | 5 | mypy==0.910 | |
| 5 | - pytest | ||
| 6 | + pylint==2.12.2 | ||
| 7 | + pytest==6.2.5 | ||
| 6 | 8 | types-PyYAML==6.0.1 | |
| 7 | 9 | types-requests==2.26.1 | |
| 8 | 10 | types-setuptools==57.4.4 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,19 +9,13 @@ setenv = VIRTUAL_ENV={envdir} | |||
| 9 | 9 | whitelist_externals = true | |
| 10 | 10 | usedevelop = True | |
| 11 | 11 | install_command = pip install {opts} {packages} | |
| 12 | + isolated_build = True | ||
| 12 | 13 | ||
| 13 | 14 | deps = -r{toxinidir}/requirements.txt | |
| 14 | 15 | -r{toxinidir}/requirements-test.txt | |
| 15 | 16 | commands = | |
| 16 | 17 | pytest tests/unit tests/meta {posargs} | |
| 17 | 18 | ||
| 18 | - [testenv:pep8] | ||
| 19 | - basepython = python3 | ||
| 20 | - envdir={toxworkdir}/lint | ||
| 21 | - deps = -r{toxinidir}/requirements-lint.txt | ||
| 22 | - commands = | ||
| 23 | - flake8 {posargs} . | ||
| 24 | - | ||
| 25 | 19 | [testenv:black] | |
| 26 | 20 | basepython = python3 | |
| 27 | 21 | envdir={toxworkdir}/lint | |
@@ -43,6 +37,20 @@ deps = -r{toxinidir}/requirements-lint.txt | |||
| 43 | 37 | commands = | |
| 44 | 38 | mypy {posargs} | |
| 45 | 39 | ||
| 40 | + [testenv:pep8] | ||
| 41 | + basepython = python3 | ||
| 42 | + envdir={toxworkdir}/lint | ||
| 43 | + deps = -r{toxinidir}/requirements-lint.txt | ||
| 44 | + commands = | ||
| 45 | + flake8 {posargs} . | ||
| 46 | + | ||
| 47 | + [testenv:pylint] | ||
| 48 | + basepython = python3 | ||
| 49 | + envdir={toxworkdir}/lint | ||
| 50 | + deps = -r{toxinidir}/requirements-lint.txt | ||
| 51 | + commands = | ||
| 52 | + pylint {posargs} gitlab/ | ||
| 53 | + | ||
| 46 | 54 | [testenv:twine-check] | |
| 47 | 55 | basepython = python3 | |
| 48 | 56 | deps = -r{toxinidir}/requirements.txt | |
| Back | FazBrowse Home | New Git URL |
0 commit comments