Skip to content

Commit

Permalink
Merge pull request #242 from specklesystems/gergo/pre-commit
Browse files Browse the repository at this point in the history
gergo/pre commit
  • Loading branch information
gjedlicska authored Dec 21, 2022
2 parents f36d63a + afb9065 commit b6b0a5a
Show file tree
Hide file tree
Showing 51 changed files with 1,652 additions and 851 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@
"postCreateCommand": "poetry config virtualenvs.create false && poetry install",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
}
2 changes: 1 addition & 1 deletion .devcontainer/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ services:
command: /bin/sh -c "while sleep 1000; do :; done"
network_mode: host
# networks:
# default:
# default:
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
* text=auto eol=lf
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,4 @@ venv.bak/

# other
scratch.py
settings.json
settings.json
33 changes: 33 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
hooks:
- id: ruff
rev: v0.0.186

- repo: https://github.com/commitizen-tools/commitizen
hooks:
- id: commitizen
- id: commitizen-branch
stages:
- push
rev: v2.38.0

- repo: https://github.com/pycqa/isort
rev: v5.11.3
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
- id: black
# It is recommended to specify the latest version of Python
# supported by your project here, or alternatively use
# pre-commit's default_language_version, see
# https://pre-commit.com/#top_level-default_language_version
# language_version: python3.11
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"name": "Python: Current File",
"type": "python",
Expand All @@ -23,4 +23,4 @@
"justMyCode": true
}
]
}
}
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ What is Speckle? Check our ![YouTube Video Views](https://img.shields.io/youtube
Give Speckle a try in no time by:

- [![speckle XYZ](https://img.shields.io/badge/https://-speckle.xyz-0069ff?style=flat-square&logo=hackthebox&logoColor=white)](https://speckle.xyz) ⇒ creating an account at our public server
- [![create a droplet](https://img.shields.io/badge/Create%20a%20Droplet-0069ff?style=flat-square&logo=digitalocean&logoColor=white)](https://marketplace.digitalocean.com/apps/speckle-server?refcode=947a2b5d7dc1) ⇒ deploying an instance in 1 click
- [![create a droplet](https://img.shields.io/badge/Create%20a%20Droplet-0069ff?style=flat-square&logo=digitalocean&logoColor=white)](https://marketplace.digitalocean.com/apps/speckle-server?refcode=947a2b5d7dc1) ⇒ deploying an instance in 1 click

### Resources

Expand All @@ -47,7 +47,7 @@ Give Speckle a try in no time by:

## Usage

Send and receive data from a Speckle Server with `operations`, interact with the Speckle API with the `SpeckleClient`, create and extend your own custom Speckle Objects with `Base`, and more!
Send and receive data from a Speckle Server with `operations`, interact with the Speckle API with the `SpeckleClient`, create and extend your own custom Speckle Objects with `Base`, and more!

Head to the [**📚 specklepy docs**](https://speckle.guide/dev/python.html) for more information and usage examples.

Expand All @@ -65,6 +65,12 @@ To execute any python script run `$ poetry run python my_script.py`

> Alternatively you may roll your own virtual-env with either venv, virtualenv, pyenv-virtualenv etc. Poetry will play along an recognize if it is invoked from inside a virtual environment.
### Style guide

All our repo wide styling linting and other rules are checked and enforced by `pre-commit`, which is included in the dev dependencies.
It is recommended to set up `pre-commit` after installing the dependencies by running `$ pre-commit install`.
Commiting code that doesn't adhere to the given rules, will fail the checks in our CI system.

### Local Data Paths

It may be helpful to know where the local accounts and object cache dbs are stored. Depending on on your OS, you can find the dbs at:
Expand All @@ -82,7 +88,7 @@ The Speckle Community hangs out on [the forum](https://discourse.speckle.works),

## Security

For any security vulnerabilities or concerns, please contact us directly at security[at]speckle.systems.
For any security vulnerabilities or concerns, please contact us directly at security[at]speckle.systems.

## License

Expand Down
1 change: 0 additions & 1 deletion example/many_children.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def clean_db():


def one_pass(clean: bool, randomize: bool, child_count: int):

foo = Base()
for i in range(child_count):
stuff = random_string() if randomize else "stuff"
Expand Down
15 changes: 15 additions & 0 deletions example/send_receive.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from devtools import debug

from specklepy.api import operations
from specklepy.api.wrapper import StreamWrapper

if __name__ == "__main__":
stream_url = "https://latest.speckle.dev/streams/7d051a6449"
wrapper = StreamWrapper(stream_url)

transport = wrapper.get_transport()

rec = operations.receive("98396753f8bf7fe1cb60c5193e9f9d86", transport)

# hash = operations.send(base=foo, transports=[transport], use_default_cache=False)
debug(rec)
1 change: 0 additions & 1 deletion example/stream_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def create_object(child_count: int) -> Base:


if __name__ == "__main__":

stream_url = "http://hyperion:3000/streams/2372b54c35"

child_count = 10
Expand Down
3 changes: 2 additions & 1 deletion example/units_none.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from devtools import debug

from specklepy.api import operations
from specklepy.objects.geometry import Base
from specklepy.objects.units import Units
Expand All @@ -13,7 +15,6 @@
for prop, value in dct.items():
base.__setattr__(prop, value)

from devtools import debug

debug(base)
debug(base.units)
Expand Down
2 changes: 1 addition & 1 deletion patch_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def patch(tag):
lines = f.readlines()

if "version" not in lines[2]:
raise Exception(f"Invalid pyproject.toml. Could not patch version.")
raise Exception("Invalid pyproject.toml. Could not patch version.")

lines[2] = f'version = "{tag}"\n'
with open("pyproject.toml", "w") as file:
Expand Down
Loading

0 comments on commit b6b0a5a

Please sign in to comment.