Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: add initial pylint check#1729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nejch merged 3 commits intomainfromjlvillal/pylint
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions.github/workflows/lint.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,3 +35,5 @@ jobs:
run: tox -e mypy
- name: Run isort import order checker (https://pycqa.github.io/isort/)
run: tox -e isort -- --check
- name: Run pylint Python code static checker (https://www.pylint.org/)
run: tox -e pylint
32 changes: 32 additions & 0 deletions.github/workflows/pre_commit.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
name: pre_commit

on:
push:
branches:
- main
paths:
.github/workflows/pre_commit.yml
.pre-commit-config.yaml
pull_request:
branches:
- main
- master
paths:
- .github/workflows/pre_commit.yml
- .pre-commit-config.yaml

env:
PY_COLORS: 1

jobs:

pre_commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- run: pip install --upgrade -r requirements.txt -r requirements-lint.txt pre-commit
- name: Run pre-commit install
run: pre-commit install
- name: pre-commit run all-files
run: pre-commit run --all-files
10 changes: 10 additions & 0 deletions.pre-commit-config.yaml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,10 +20,20 @@ repos:
rev: 5.9.3
hooks:
- id: isort
- repo: https://github.com/pycqa/pylint
rev: v2.12.2
hooks:
- id: pylint
additional_dependencies:
- argcomplete==1.12.3
- requests==2.26.0
- requests-toolbelt==0.9.1
files: 'gitlab/'
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.910
hooks:
- id: mypy
args: []
additional_dependencies:
- types-PyYAML==6.0.1
- types-requests==2.26.1
Expand Down
17 changes: 9 additions & 8 deletionsgitlab/v4/objects/merge_request_approvals.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -140,7 +140,7 @@ def set_approvers(
approval_rules: ProjectMergeRequestApprovalRuleManager = (
self._parent.approval_rules
)
""" update any existing approval rule matching the name"""
# update any existing approval rule matching the name
existing_approval_rules = approval_rules.list()
for ar in existing_approval_rules:
if ar.name == approval_rule_name:
Expand All@@ -149,7 +149,7 @@ def set_approvers(
ar.group_ids = data["group_ids"]
ar.save()
return ar
""" if there was no rule matching the rule name, create a new one"""
# if there was no rule matching the rule name, create a new one
return approval_rules.create(data=data)


Expand All@@ -171,13 +171,13 @@ def save(self, **kwargs: Any) -> None:
GitlabAuthenticationError: If authentication is not correct
GitlabUpdateError: If the server cannot perform the request
"""
# There is a mismatch between the name of our id attribute and the put REST API name for the
# project_id, so we override it here.
# There is a mismatch between the name of our id attribute and the put
#REST API name for theproject_id, so we override it here.
self.approval_rule_id = self.id
self.merge_request_iid = self._parent_attrs["mr_iid"]
self.id = self._parent_attrs["project_id"]
# save will update self.id with the result from the server, so no need to overwrite with
# what it was before we overwrote it."""
# save will update self.id with the result from the server, so no need
#to overwrite withwhat it was before we overwrote it.
SaveMixin.save(self, **kwargs)


Expand All@@ -198,8 +198,9 @@ class ProjectMergeRequestApprovalRuleManager(
),
optional=("user_ids", "group_ids"),
)
# Important: When approval_project_rule_id is set, the name, users and groups of
# project-level rule will be copied. The approvals_required specified will be used. """
# Important: When approval_project_rule_id is set, the name, users and
# groups of project-level rule will be copied. The approvals_required
# specified will be used.
_create_attrs = RequiredOptional(
required=("id", "merge_request_iid", "name", "approvals_required"),
optional=("approval_project_rule_id", "user_ids", "group_ids"),
Expand Down
17 changes: 12 additions & 5 deletionsgitlab/v4/objects/projects.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -597,10 +597,12 @@ def artifact(
chunk_size: int = 1024,
**kwargs: Any,
) -> Optional[bytes]:
"""Download a single artifact file from a specific tag or branch from within the job’s artifacts archive.
"""Download a single artifact file from a specific tag or branch from
within the job’s artifacts archive.

Args:
ref_name: Branch or tag name in repository. HEAD or SHA references are not supported.
ref_name: Branch or tag name in repository. HEAD or SHA references
are not supported.
artifact_path: Path to a file inside the artifacts archive.
job: The name of the job.
streamed: If True the data will be processed by chunks of
Expand All@@ -619,7 +621,10 @@ def artifact(
The artifacts if `streamed` is False, None otherwise.
"""

path = f"/projects/{self.get_id()}/jobs/artifacts/{ref_name}/raw/{artifact_path}?job={job}"
path = (
f"/projects/{self.get_id()}/jobs/artifacts/{ref_name}/raw/"
f"{artifact_path}?job={job}"
)
result = self.manager.gitlab.http_get(
path, streamed=streamed, raw=True, **kwargs
)
Expand DownExpand Up@@ -857,7 +862,8 @@ def import_bitbucket_server(

.. note::
This request may take longer than most other API requests.
So this method will specify a 60 second default timeout if none is specified.
So this method will specify a 60 second default timeout if none is
specified.
A timeout can be specified via kwargs to override this functionality.

Args:
Expand DownExpand Up@@ -945,7 +951,8 @@ def import_github(

.. note::
This request may take longer than most other API requests.
So this method will specify a 60 second default timeout if none is specified.
So this method will specify a 60 second default timeout if none is
specified.
A timeout can be specified via kwargs to override this functionality.

Args:
Expand Down
47 changes: 47 additions & 0 deletionspyproject.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -41,3 +41,50 @@ branch = "main"
version_variable = "gitlab/__version__.py:__version__"
commit_subject = "chore: release v{version}"
commit_message = ""

[tool.pylint.messages_control]
max-line-length = 88
# TODO(jlvilla): Work on removing these disables over time.
disable = [
"arguments-differ",
"arguments-renamed",
"attribute-defined-outside-init",
"broad-except",
"consider-using-f-string",
"consider-using-generator",
"consider-using-sys-exit",
"cyclic-import",
"duplicate-code",
"expression-not-assigned",
"fixme",
"implicit-str-concat",
"import-outside-toplevel",
"invalid-name",
"missing-class-docstring",
"missing-function-docstring",
"missing-module-docstring",
"no-else-return",
"no-self-use",
"protected-access",
"raise-missing-from",
"redefined-builtin",
"redefined-outer-name",
"signature-differs",
"super-with-arguments",
"too-few-public-methods",
"too-many-ancestors",
"too-many-arguments",
"too-many-branches",
"too-many-instance-attributes",
"too-many-lines",
"too-many-locals",
"too-many-statements",
"unexpected-keyword-arg",
"unnecessary-pass",
"unspecified-encoding",
"unsubscriptable-object",
"unused-argument",
"useless-import-alias",
"useless-object-inheritance",

]
4 changes: 3 additions & 1 deletionrequirements-lint.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
argcomplete==1.12.3
black==21.12b0
flake8==4.0.1
isort==5.10.1
mypy==0.910
pytest
pylint==2.12.2
pytest==6.2.5
types-PyYAML==6.0.1
types-requests==2.26.1
types-setuptools==57.4.4
22 changes: 15 additions & 7 deletionstox.ini
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,19 +9,13 @@ setenv = VIRTUAL_ENV={envdir}
whitelist_externals = true
usedevelop = True
install_command = pip install {opts} {packages}
isolated_build = True

deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/requirements-test.txt
commands =
pytest tests/unit tests/meta {posargs}

[testenv:pep8]
basepython = python3
envdir={toxworkdir}/lint
deps = -r{toxinidir}/requirements-lint.txt
commands =
flake8 {posargs} .

[testenv:black]
basepython = python3
envdir={toxworkdir}/lint
Expand All@@ -43,6 +37,20 @@ deps = -r{toxinidir}/requirements-lint.txt
commands =
mypy {posargs}

[testenv:pep8]
basepython = python3
envdir={toxworkdir}/lint
deps = -r{toxinidir}/requirements-lint.txt
commands =
flake8 {posargs} .

[testenv:pylint]
basepython = python3
envdir={toxworkdir}/lint
deps = -r{toxinidir}/requirements-lint.txt
commands =
pylint {posargs} gitlab/

[testenv:twine-check]
basepython = python3
deps = -r{toxinidir}/requirements.txt
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp