Skip to content

Commit 426af11

Browse files
committed
lintfiles
1 parent e233f87 commit 426af11

File tree

7 files changed

+136
-75
lines changed

7 files changed

+136
-75
lines changed

.github/workflows/python-app.yml

+63-29
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,76 @@
1-
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3-
4-
name: Test workflow
1+
name: CI
52

63
on:
74
push:
8-
branches: [ master ]
5+
branches: [master]
96
pull_request:
10-
branches: [ master ]
7+
branches: [master]
8+
9+
env:
10+
DEFAULT_PYTHON: "3.10"
1111

1212
permissions:
1313
contents: read
1414

1515
jobs:
16-
build:
16+
ruff:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v3
20+
- uses: chartboost/ruff-action@v1
21+
22+
black:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v3
26+
- uses: actions/setup-python@v3
27+
with:
28+
python-version: ${{ env.DEFAULT_PYTHON }}
29+
- uses: psf/[email protected]
1730

31+
pylint:
1832
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v3
35+
- uses: actions/setup-python@v4
36+
with:
37+
python-version: ${{ env.DEFAULT_PYTHON }}
38+
- name: Install dependencies
39+
run: |
40+
python -m pip install --upgrade pip
41+
pip install -r requirements.txt
42+
pip install -r requirements-dev.txt
43+
- name: Run Pylint
44+
run: |
45+
pylint office365
1946
47+
pytest:
48+
runs-on: ubuntu-latest
49+
needs:
50+
- ruff
51+
- black
52+
- pylint
2053
steps:
21-
- uses: actions/checkout@v3
22-
- name: Set up Python 3.10
23-
uses: actions/setup-python@v3
24-
with:
25-
python-version: "3.10"
26-
- name: Install dependencies
27-
run: |
28-
python -m pip install --upgrade pip
29-
pip install flake8 pytest
30-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
31-
- name: Lint with flake8
32-
run: |
33-
# stop the build if there are Python syntax errors or undefined names
34-
flake8 office365 --count --select=E9,F63,F7,F82 --show-source --statistics
35-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
36-
flake8 office365 --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
37-
- name: Test with pytest
38-
env:
39-
office365_python_sdk_securevars: ${{ secrets.OFFICE365_PYTHON_SDK_SECUREVARS }}
40-
run: |
41-
echo "${{env.office365_python_sdk_securevars}}"
42-
pytest
54+
- uses: actions/checkout@v3
55+
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
56+
uses: actions/setup-python@v3
57+
with:
58+
python-version: ${{ env.DEFAULT_PYTHON }}
59+
- name: Install dependencies
60+
run: |
61+
python -m pip install --upgrade pip
62+
pip install -r requirements.txt
63+
pip install -r requirements-dev.txt
64+
- name: Test with pytest
65+
env:
66+
office365_python_sdk_securevars: ${{ secrets.OFFICE365_PYTHON_SDK_SECUREVARS }}
67+
run: |
68+
echo "${{env.office365_python_sdk_securevars}}"
69+
pytest
70+
71+
# - name: Lint with flake8
72+
# run: |
73+
# # stop the build if there are Python syntax errors or undefined names
74+
# flake8 office365 --count --select=E9,F63,F7,F82 --show-source --statistics
75+
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
76+
# flake8 office365 --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

.pre-commit-config.yaml

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.0.292
4+
hooks:
5+
- id: ruff
6+
args: [--fix, --exit-non-zero-on-fix]
27
- repo: https://github.com/psf/black
38
rev: 23.9.1
49
hooks:
510
- id: black
611
args:
712
- --quiet
8-
9-
- repo: https://github.com/PyCQA/isort
10-
rev: 5.12.0
11-
hooks:
12-
- id: isort
13-
args:
14-
- --profile=black

office365/entity_collection.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
<<<<<<< HEAD
21
from typing import TYPE_CHECKING, Any, Optional, Type, TypeVar
3-
=======
4-
from typing import TYPE_CHECKING, Any, TypeVar
5-
>>>>>>> 3ecd282d (isort)
62

73
from office365.entity import Entity
84
from office365.runtime.client_object_collection import ClientObjectCollection
@@ -32,7 +28,7 @@ def __getitem__(self, key):
3228
:param key: key is used to address an entity by either an index or by identifier
3329
:type key: int or str
3430
"""
35-
if type(key) == int:
31+
if isinstance(key, int):
3632
return super(EntityCollection, self).__getitem__(key)
3733
elif is_string_type(key):
3834
return self.create_typed_object(

pyproject.toml

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
[tool.ruff]
2+
line-length = 121
3+
# pyflakes, pycodestyle, isort
4+
select = ["F", "E", "W", "I001"]
5+
6+
[tool.pylint]
7+
max-line-length = 120
8+
disable = [
9+
"C0103",
10+
"C0111",
11+
"C0112", # empty-docstring
12+
"C0114", # missing-module-docstring
13+
"C0201", # consider-iterating-dictionary (Python 2)
14+
"C0206", # consider-using-dict-items (Python 2)
15+
"C0209", # consider-using f-string
16+
"C0302", # too-many-lines
17+
"C0303",
18+
"C0415", # import-outside-toplevel
19+
"E0307", # invalid-str-returned
20+
"E0611", # no-name-in-module (!)
21+
"E1102", # not-callable
22+
"R0205", # useless-object-inheritance (Python 2)
23+
"R0401", # cyclic-import (!)
24+
"R0801", # duplicate-code
25+
"R0902", # too-many-instance-attributes
26+
"R0903", # too-few-public-methods
27+
"R0903", # too-few-public-methods
28+
"R0904", # too-many-public-methods
29+
"R0912", # too-many-branches
30+
"R0913", # too-many-arguments
31+
"R0914", # too-many-locals
32+
"R1705", # no-else-return
33+
"R1710", # inconsistent-return-statements (!)
34+
"R1711", # useless-return
35+
"R1714", # consider-using-in
36+
"R1720", # no-else-raise
37+
"R1721", # unnecessary-comprehension
38+
"R1725", # super-with-arguments
39+
"R1732", #consider-using-with
40+
"W0105", # pointless-string-statement
41+
"W0106", # expression-not-assigned
42+
"W0107", # unnecessary-pass
43+
"W0201", # attribute-defined-outside-init
44+
"W0212", # protected-access
45+
"W0221", # arguments-differ
46+
"W0237", # arguments-renamed
47+
"W0246", # useless-parent-delegation
48+
"W0404", # reimported
49+
"W0613", # unused-argument
50+
"W0621", # redefine-outer-name
51+
"W0707", # raise-missing-from
52+
"W1113", # keyword-arg-before-vararg
53+
"W3101", # missing-timeout
54+
] # all codes: http://pylint-messages.wikidot.com/all-codes
55+
56+
[tool.pylint.FORMAT]
57+
max-line-length = 121
58+
ignore-long-lines = '^\s*# (<?https?://\S+>?|type: .+)$'
59+
60+
[tool.pylint.MASTER]
61+
ignore-patterns = 'office365\todo\tasks\**'
62+
63+
[tool.ruff.per-file-ignores]
64+
"tests/**/*.py" = ["F401"]
65+
"examples/**/*.py" = ["F401"]
66+
"office365/**/*.py" = ["F401"]

requirements-dev.txt

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ Faker~=4.1.2
88
adal~=1.2.4
99
configparser~=5.0.2
1010
black
11+
pylint

requirements.txt

-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,4 @@ requests_ntlm [NTLMAuthentication]
33
setuptools==65.5.1
44
msal==1.24.1
55
pytz==2021.1
6-
<<<<<<< HEAD
76
typing_extensions>=4.0.0;python_version<'3.11'
8-
=======
9-
typing_extensions
10-
>>>>>>> 3ecd282d (isort)

setup.cfg

-30
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,2 @@
11
[metadata]
22
description-file = README.md
3-
4-
[isort]
5-
profile=black
6-
7-
[flake8]
8-
# These error codes can be fixed, but since it touches many files the
9-
# suggestion is to do it one code at a time to reduce review effort
10-
# F401 - imported but unused
11-
# F841 - local variable defined but never used
12-
extend-ignore = E203, E501, W503, F401, F841
13-
max-line-length = 88
14-
exclude =
15-
generator/metadata
16-
office365/runtime/compat.py
17-
18-
[pylint]
19-
max-line-length=120
20-
# all codes: http://pylint-messages.wikidot.com/all-codes
21-
disable=
22-
C0103,
23-
C0303,
24-
C0111,
25-
C0415, # import-outside-toplevel
26-
C0112, # empty-docstring
27-
C0209, # consider-using f-string
28-
C0114, # missing-module-docstring
29-
R1725, # super-with-arguments
30-
31-
[pylint.FORMAT]
32-
max-line-length = 121

0 commit comments

Comments
 (0)