Skip to content

Commit

Permalink
Merge pull request #256 from nationalarchives/chore/use-ruff
Browse files Browse the repository at this point in the history
Swap to using Ruff instead of Flake8
  • Loading branch information
jacksonj04 authored Nov 9, 2023
2 parents b8d60d6 + 6ceb781 commit 4cdab79
Show file tree
Hide file tree
Showing 17 changed files with 304 additions and 275 deletions.
9 changes: 4 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ repos:
hooks:
- id: black

- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.4
hooks:
- id: flake8
args: ["--config=setup.cfg"]
additional_dependencies: [flake8-isort]
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.6.1 # Use the sha / tag you want to point at
Expand Down
214 changes: 111 additions & 103 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,56 @@ info:
title: Case Law Privileged API
version: 0.1.2
servers:
- url: "https://{environment}.caselaw.nationalarchives.gov.uk/v1"
variables:
environment:
default: api
enum:
- api
- api.staging
- url: "https://{environment}.caselaw.nationalarchives.gov.uk/v1"
variables:
environment:
default: api
enum:
- api
- api.staging
tags:
- description: Verify the operational state of the API
name: Status
- description: Operations for reading document content and metadata
name: Reading
- description: Operations for writing document content and metadata
name: Writing
- description: Verify the operational state of the API
name: Status
- description: Operations for reading document content and metadata
name: Reading
- description: Operations for writing document content and metadata
name: Writing
paths:
/status:
get:
description: "A test endpoint that can be used by clients to verify service\
description:
"A test endpoint that can be used by clients to verify service\
\ availability, and to verify valid authentication credentials.\nAuthentication\
\ is not required, but if it is provided, it will be checked for validity.\n"
responses:
"200":
description: "The service is available, and if authentication was provided,\
description:
"The service is available, and if authentication was provided,\
\ the authentication is valid."
"401":
description: "The service is available, but the provided authentication\
description:
"The service is available, but the provided authentication\
\ was not valid."
security:
- {}
- basic: []
- {}
- basic: []
summary: Health check
tags:
- Status
- Status
/{judgmentUri}:
get:
description: "Unless the client has `read_unpublished_documents` permission,\
description:
"Unless the client has `read_unpublished_documents` permission,\
\ then only published documents are accessible."
operationId: getDocumentByUri
parameters:
- explode: false
in: path
name: judgmentUri
required: true
schema:
type: string
style: simple
- explode: false
in: path
name: judgmentUri
required: true
schema:
type: string
style: simple
responses:
"200":
description: "A single judgment document, in Akoma Ntoso XML"
Expand All @@ -61,40 +65,42 @@ paths:
type: string
style: simple
X-Lock-State:
description: Included if the client has the `write_documents` role;
description:
Included if the client has the `write_documents` role;
specifies if the document is currently locked for editing.
example: true
explode: false
schema:
type: boolean
style: simple
security:
- basic:
- read_documents
- read_unpublished_documents
- basic:
- read_documents
- read_unpublished_documents
summary: "Read a judgment or decision, given its URI"
tags:
- Reading
- Reading
put:
description: "Write a complete new version of the document to the database,\
description:
"Write a complete new version of the document to the database,\
\ and release any client lock."
parameters:
- explode: false
in: path
name: judgmentUri
required: true
schema:
type: string
style: simple
- description: The last known version number of the document
example: "1"
explode: false
in: header
name: If-Match
required: true
schema:
type: string
style: simple
- explode: false
in: path
name: judgmentUri
required: true
schema:
type: string
style: simple
- description: The last known version number of the document
example: "1"
explode: false
in: header
name: If-Match
required: true
schema:
type: string
style: simple
responses:
"204":
description: The document was updated successfully and any client lock released
Expand All @@ -107,54 +113,52 @@ paths:
style: simple
"400":
description: "The request was malformed, and the document was not modified"
"412":
description: "The document was not updated, as it has changed since the\
\ version number specified If-Match. To avoid this, the client should\
\ lock the document before making any changes to it."
security:
- basic:
- write_documents
- basic:
- write_documents
summary: Update a judgment
tags:
- Writing
- Writing
/{judgmentUri}/lock:
get:
parameters:
- explode: false
in: path
name: judgmentUri
required: true
schema:
type: string
style: simple
- explode: false
in: path
name: judgmentUri
required: true
schema:
type: string
style: simple
responses:
"204":
description: Lock state included in header
headers:
X-Lock-State:
description: Included if the client has edit permissions; specifies
description:
Included if the client has edit permissions; specifies
if the document is currently locked for editing.
explode: false
schema:
type: boolean
style: simple
security:
- basic:
- write_documents
- basic:
- write_documents
summary: Query lock status for a document
tags:
- Writing
- Writing
put:
description: "Locks edit access for a document for the current client. Returns\
description:
"Locks edit access for a document for the current client. Returns\
\ the latest version of the locked document, alohg with the new lock state."
parameters:
- explode: false
in: path
name: judgmentUri
required: true
schema:
type: string
style: simple
- explode: false
in: path
name: judgmentUri
required: true
schema:
type: string
style: simple
responses:
"201":
description: "A single judgment document, in Akoma Ntoso XML"
Expand All @@ -167,7 +171,8 @@ paths:
type: string
style: simple
X-Lock-State:
description: Included if the client has the `write_documents` role;
description:
Included if the client has the `write_documents` role;
specifies if the document is currently locked for editing.
example: true
explode: false
Expand All @@ -178,58 +183,60 @@ paths:
description: The document was already locked by another client
headers:
X-Lock-State:
description: Included if the client has edit permissions; specifies
description:
Included if the client has edit permissions; specifies
if the document is currently locked for editing.
explode: false
schema:
type: boolean
style: simple
security:
- basic:
- write_documents
- basic:
- write_documents
summary: Lock access to a document
tags:
- Writing
- Writing
/{judgmentUri}/metadata:
get:
description: "Unless the client has `read_unpublished_documents` permission,\
description:
"Unless the client has `read_unpublished_documents` permission,\
\ then only metadata for published documents are accessible."
parameters:
- explode: false
in: path
name: judgmentUri
required: true
schema:
type: string
style: simple
- explode: false
in: path
name: judgmentUri
required: true
schema:
type: string
style: simple
responses:
"200":
description: OK
security:
- basic:
- read_documents
- read_unpublished_documents
- basic:
- read_documents
- read_unpublished_documents
summary: Gets the document's metadata
tags:
- Reading
- Reading
patch:
parameters:
- explode: false
in: path
name: judgmentUri
required: true
schema:
type: string
style: simple
- explode: false
in: path
name: judgmentUri
required: true
schema:
type: string
style: simple
responses:
"200":
description: OK
security:
- basic:
- write_documents
- basic:
- write_documents
summary: Set document properties
tags:
- Writing
- Writing
components:
parameters:
judgmentUri:
Expand Down Expand Up @@ -262,7 +269,8 @@ components:
type: string
style: simple
X-Lock-State:
description: Included if the client has the `write_documents` role; specifies
description:
Included if the client has the `write_documents` role; specifies
if the document is currently locked for editing.
example: true
explode: false
Expand Down
16 changes: 8 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

[project]
requires-python = ">=3.12, <4"

[tool.black]
line-length = 88
Expand All @@ -19,13 +20,12 @@ exclude = '''
)
'''

[tool.isort]
profile = "black"
skip = [
'.eggs', '.git', '.hg', '.mypy_cache', '.nox', '.pants.d', '.tox',
'.venv', '_build', 'buck-out', 'build', 'dist', 'node_modules', 'venv',
]
skip_gitignore = true
[tool.ruff]
ignore = ["S101", "E501", "G004", "PLR2004", "RUF005", "RUF012"]
extend-select = ["W", "B", "Q", "C90", "I", "UP", "YTT", "ASYNC", "S", "BLE", "A", "COM", "C4", "DTZ", "T10", "DJ", "EM", "EXE", "FA",
"ISC", "ICN", "G", "INP", "PIE", "T20", "PYI", "PT", "Q", "RSE", "RET", "SLF", "SLOT", "SIM", "TID", "TCH", "INT", "PTH",
"FIX", "PGH", "PL", "TRY", "FLY", "PERF", "RUF"]
unfixable = ["ERA"]

[tool.poetry]
name = "ds-caselaw-privileged-api"
Expand Down
Loading

0 comments on commit 4cdab79

Please sign in to comment.