Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pre commit #459

Merged
merged 6 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 1 addition & 7 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.7.13, 3.8, 3.9]
python: [3.8, 3.9, 3.12]
steps:
- name: Checkout WrapanAPI
uses: actions/checkout@v3
Expand All @@ -35,11 +35,5 @@ jobs:
pip install --compile --no-cache-dir pycurl
pip install -U -e .[test]

# coming soon
#- name: Pre Commit Checks
# uses: pre-commit/[email protected]
# with:
# extra_args: --show-diff-on-failure

- name: Run Unit Tests
run: py.test tests/ -v --cov wrapanapi
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
.pytest_cache/
.coverage
.venv*
dist/
.eggs
*.egg-info
.env/
.idea/
*.vars.json
.tox/
AUTHORS
ChangeLog
ChangeLog
33 changes: 33 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
ci:
autofix_prs: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its potentially helpful to leave this, eases the life for drive by contributors that just messed up syntax

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave it set to false as contributors might not realize that someone/something else pushed new commits to their branch. I would expect contributors to have pre-commit installed locally, therefore they should run the checks before pushing the commit - either as an actual git hook or manually by pre-commit run.

There is still the possibility to fix it by adding a pre-commit.ci autofix comment to the PR. See https://pre-commit.ci/#configuration-autofix_prs

repos:
- repo: https://github.com/asottile/reorder_python_imports
rev: v3.9.0
hooks:
- id: reorder-python-imports
args:
- --application-directories=.:wrapanapi
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
args: [--safe, --quiet, --line-length, "100"]
mshriver marked this conversation as resolved.
Show resolved Hide resolved
require_serial: true
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
args:
- --max-line-length=100
- --ignore=W503,E203
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: debug-statements
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.2
hooks:
- id: pyupgrade
args: [--py3-plus, --py38-plus]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Each management system is invoked usually with a hostname and some credentials
.. code-block:: python

from wrapanapi.virtualcenter import VMWareSystem

system = VMWareSystem(hostname='10.0.0.0', username="root", password="password")
system.list_vm()

Expand All @@ -90,15 +90,15 @@ it doesn't support. This behaviour may change in the future as more and more div
from base import WrapanapiAPIBase

class RHEVMSystem(WrapanapiAPIBase):

_stats_available = {
'num_vm': lambda self: self.api.get_summary().get_vms().total,
'num_host': lambda self: len(self.list_host()),
'num_cluster': lambda self: len(self.list_cluster()),
'num_template': lambda self: len(self.list_template()),
'num_datastore': lambda self: len(self.list_datastore()),
}

def __init__(self, hostname, username, password, **kwargs):
super(RHEVMSystem, self).__init__(kwargs)

Expand All @@ -116,5 +116,5 @@ This module was originally developed for assisting in the ManageIQ testing team.

Contributing
------------
The guidelines to follow for this project can be found in the
The guidelines to follow for this project can be found in the
cfme `dev_guide <http://cfme-tests.readthedocs.org/guides/dev_guide.html>`_.
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ dependencies = [
]

[project.optional-dependencies]
dev = [
"pre-commit",
]
test = [
"mock",
"pytest",
Expand Down
1 change: 0 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
# -*- coding: utf-8 -*-
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"Password" : "sa"
},
"name" : "configuration"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"Password" : "sa"
},
"name" : "configuration"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"Password" : "sa"
},
"name" : "configuration"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"Password" : "sa"
},
"name" : "configuration"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,3 @@
"id": "Hawkular WildFly Agent"
}
]

Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"Password" : "sa"
},
"name" : "configuration"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"Password" : "sa"
},
"name" : "configuration"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"Password" : "sa"
},
"name" : "configuration"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"Password" : "sa"
},
"name" : "configuration"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"Password" : "sa"
},
"name" : "configuration"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"Password" : "sa"
},
"name" : "configuration"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"Password" : "sa"
},
"name" : "configuration"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"Password" : "sa"
},
"name" : "configuration"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"Password" : "sa"
},
"name" : "configuration"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"Password" : "sa"
},
"name" : "configuration"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"Server State": "running",
"Product Name": "WildFly Full",
"Local Host Name": "skondkar-hawkular.bc.jonqe.lab.eng.bos.redhat.com"

},
"name": "configuration"
}
2 changes: 1 addition & 1 deletion tests/resources/hawkular/inventory/status.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"Built-From-Git-SHA1": "3c8ac6648aa0ec33643ae1b98faadc475d2c6f02",
"Inventory-Implementation": "org.hawkular.inventory.impl.tinkerpop.TinkerpopInventory",
"Initialized": "true"
}
}
2 changes: 1 addition & 1 deletion tests/resources/hawkular/metrics/status.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"Implementation-Version":"0.26.0.Final",
"Built-From-Git-SHA1":"fe3ef3ccc36a0c85bcdbf3e96aae8d36a636f7f2",
"Cassandra":"up"
}
}
Loading