Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
touilleMan committed Nov 17, 2023
1 parent a01f21e commit e5a6f8a
Show file tree
Hide file tree
Showing 514 changed files with 17,493 additions and 44,671 deletions.
33 changes: 21 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ repos:
# - lastly, mypy is started
# So this is similar to what the developer does when running mypy from it dev shell \o/
#
# Now that we use poetry to run mypy, why not also use it for ruff & black !
# Now that we use poetry to run mypy, why not also use it for ruff linter & formatter !
# This have the following benefits:
# - It prevents going out of sync in tools version between pre-commit-config
# and poetry.lock
Expand All @@ -107,26 +107,35 @@ repos:
hooks:
- id: ruff
name: ruff (using `poetry run ruff`)
entry: poetry --directory ./server run ruff check
# Wow this looks ugly ! But there is a reason why:
# - Ruff's `extend-exclude` doesn't work if it is not run from it config's folder
# - Pre-commit only run script from the repo root directory
# - A file passed as parameter is check by Ruff even if it part of `extend-exclude`
# - Splitting lines with YAML add heading whitespaces for no reason, and Python
# then complains about indentation :'(
#
# So (after a lot of pain) we came up with this: a one liner (because YAML)
# of a Python script that jumps in the correct directory (because pre-commit)
# to run Ruff on the whole codebase (because Ruff).
#
# Fortunatly Ruff is (as cool kids say) blazingly fast, so it's no big

Check warning on line 121 in .pre-commit-config.yaml

View workflow job for this annotation

GitHub Actions / spelling / cspell

Unknown word (Fortunatly)
# deal to check everything on each run.
entry:
poetry --directory ./server run python -c 'import os;os.chdir("./server");os.execlp("ruff", "ruff", "check", "./parsec", "./tests", "../docs", "../make.py", "../misc");'
require_serial: true
pass_filenames: false
language: system
types_or: [ python, pyi ]
args:
[
--config=server/pyproject.toml,
--extend-exclude=client/*,
--fix,
]

- id: black
name: black (using `poetry run black`)
entry: poetry --directory ./server run black
- id: black # Still named `black` as it makes a unique recognizable name
name: black (using `poetry run ruff format`)
entry: poetry --directory ./server run ruff format
require_serial: true
language: system
types_or: [ python, pyi ]
args:
[
--line-length=100,
--config=server/pyproject.toml,
]

- id: mypy
Expand Down
4 changes: 2 additions & 2 deletions bindings/generator/api/common.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 2016-present Scille SAS

from typing import Any, Generic, TypeVar
from typing import Any, ClassVar, Generic, TypeVar

#
# Meta-types
Expand Down Expand Up @@ -167,7 +167,7 @@ class DeviceLabel(StrBasedType):
class HumanHandle(Structure):
email: str
label: str
custom_getters: dict[str, str] = {
custom_getters: ClassVar = {
"email": "|obj| { fn access(obj: &libparsec::HumanHandle) -> &str { obj.email() } access(obj) }",
"label": "|obj| { fn access(obj: &libparsec::HumanHandle) -> &str { obj.label() } access(obj) }",
}
Expand Down
10 changes: 8 additions & 2 deletions bindings/generator/api/invite.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,10 @@ async def client_new_user_invitation(
client: Handle,
claimer_email: str,
send_email: bool,
) -> Result[NewInvitationInfo, NewUserInvitationError,]:
) -> Result[
NewInvitationInfo,
NewUserInvitationError,
]:
raise NotImplementedError


Expand All @@ -347,7 +350,10 @@ class Internal:
async def client_new_device_invitation(
client: Handle,
send_email: bool,
) -> Result[NewInvitationInfo, NewDeviceInvitationError,]:
) -> Result[
NewInvitationInfo,
NewDeviceInvitationError,
]:
raise NotImplementedError


Expand Down
2 changes: 1 addition & 1 deletion bindings/generator/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ def generate(what: str, api_specs: ApiSpecs) -> str | None:
parser = argparse.ArgumentParser(description="Generate bindings code")
parser.add_argument(
"what",
choices=TEMPLATE_CHOICES + ["all"],
choices=[*TEMPLATE_CHOICES, "all"],
nargs="+",
)
parser.add_argument("--test", action="store_true")
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
# on_rtd is whether we are on readthedocs.org, this line of code grabbed from docs.readthedocs.org
on_rtd = os.environ.get("READTHEDOCS", None) == "True"

import sphinx_rtd_theme
import sphinx_rtd_theme # type: ignore (we type check from the wrong virtualenv)

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
"cmd": "organization_bootstrap",
"fields": [
{
// Set to `None` for spontaneous bootstrap (i.e. the organization
// hasn't been created prior to the bootstrap)
"name": "bootstrap_token",
"type": "String"
"type": "RequiredOption<BootstrapToken>"
},
{
"name": "root_verify_key",
Expand Down Expand Up @@ -46,30 +48,17 @@
"status": "ok"
},
{
"status": "invalid_certification",
"fields": [
{
"name": "reason",
"type": "NonRequiredOption<String>"
}
]
"status": "invalid_certificate"
},
{
"status": "invalid_data",
"fields": [
{
"name": "reason",
"type": "NonRequiredOption<String>"
}
]
"status": "organization_already_bootstrapped"
},
{
"status": "bad_timestamp",
"status": "invalid_bootstrap_token"
},
{
"status": "timestamp_out_of_ballpark",
"fields": [
{
"name": "reason",
"type": "NonRequiredOption<String>"
},
{
"name": "ballpark_client_early_offset",
"type": "Float"
Expand All @@ -79,20 +68,14 @@
"type": "Float"
},
{
"name": "backend_timestamp",
"name": "server_timestamp",
"type": "DateTime"
},
{
"name": "client_timestamp",
"type": "DateTime"
}
]
},
{
"status": "already_bootstrapped"
},
{
"status": "not_found"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@
"unit": "PkiEnrollmentInfoStatus"
},
{
"status": "not_found",
"fields": [
{
"name": "reason",
"type": "NonRequiredOption<String>"
}
]
"status": "enrollment_not_found"
}
],
"nested_types": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
{
"name": "submitter_der_x509_certificate_email",
"type": "RequiredOption<String>"
"type": "String"
},
{
"name": "submit_payload_signature",
Expand All @@ -43,7 +43,7 @@
]
},
{
"status": "already_submitted",
"status": "x509_certificate_already_submitted",
"fields": [
{
"name": "submitted_on",
Expand All @@ -52,25 +52,17 @@
]
},
{
"status": "id_already_used",
"fields": []
"status": "enrollment_id_already_used"
},
{
"status": "email_already_used",
"fields": []
"status": "email_already_used"
},
{
"status": "already_enrolled",
"fields": []
},
{
"status": "invalid_payload_data",
"fields": [
{
"name": "reason",
"type": "NonRequiredOption<String>"
}
]
"status": "invalid_payload_data"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,16 @@
"status": "ok"
},
{
"status": "already_exists"
"status": "realm_not_found"
},
{
"status": "not_found"
"status": "block_already_exists"
},
{
"status": "timeout"
"status": "author_not_allowed"
},
{
"status": "not_allowed"
},
{
"status": "in_maintenance"
"status": "store_unavailable"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,13 @@
]
},
{
"status": "not_found"
"status": "block_not_found"
},
{
"status": "timeout"
"status": "author_not_allowed"
},
{
"status": "not_allowed"
},
{
"status": "in_maintenance"
"status": "store_unavailable"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,49 @@
"cmd": "certificate_get",
"fields": [
{
// Skip the certificates before this index
"name": "offset",
"type": "Index"
// Skip the certificates before (or at) this timestamp
"name": "common_after",
"type": "RequiredOption<DateTime>"
},
{
// Skip the certificates before (or at) this timestamp
"name": "sequester_after",
"type": "RequiredOption<DateTime>"
},
{
// Skip the certificates before (or at) this timestamp
"name": "shamir_after",
"type": "RequiredOption<DateTime>"
},
{
// Skip the certificates before (or at) this timestamp
"name": "realm_after",
// Key is the realm ID
"type": "Map<VlobID, RequiredOption<DateTime>>"
}
]
},
"reps": [
{
"status": "ok",
"fields": [
// Certificates are provided in-order (with strictly growing timestamps),
// their index should be calculated by `offset + <certificate's index in this list>`
// Certificates are provided in-order (i.e. with growing timestamps)
{
"name": "common_certificates",
"type": "List<Bytes>"
},
{
"name": "sequester_certificates",
"type": "List<Bytes>"
},
{
"name": "certificates",
"name": "shamir_certificates",
"type": "List<Bytes>"
},
{
"name": "realm_certificates",
// Key is the realm ID
"type": "Map<VlobID, List<Bytes>>"
}
]
}
Expand Down
Loading

0 comments on commit e5a6f8a

Please sign in to comment.