Skip to content

Commit c87760e

Browse files
authored
added recipe for python orjson and updated names (#680)
* added recipe for python orjson and updated names * Updated readme
1 parent 2dd875c commit c87760e

File tree

9 files changed

+57
-10
lines changed

9 files changed

+57
-10
lines changed

packages/codemods/python/orjson/json.dumps/.codemodrc.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
"$schema": "https://codemod-utils.s3.us-west-1.amazonaws.com/configuration_schema.json",
33
"version": "1.0.1",
44
"private": false,
5-
"name": "Converts json.dumps to orjson.dumps().decode()",
5+
"name": "python/orjson/json.dumps",
66
"engine": "ast-grep",
77
"meta": {
8-
"tags": ["python", "json", "orjson", "sentry"]
8+
"tags": ["python", "json", "orjson", "sentry"],
9+
"git": "https://github.com/codemod-com/codemod/tree/main/packages/codemods/python/orjson/json.dumps"
910
}
1011
}

packages/codemods/python/orjson/json.load/.codemodrc.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
"$schema": "https://codemod-utils.s3.us-west-1.amazonaws.com/configuration_schema.json",
33
"version": "1.0.1",
44
"private": false,
5-
"name": "Converts json.load to orjson.loads",
5+
"name": "python/orjson/json.load",
66
"engine": "ast-grep",
77
"meta": {
8-
"tags": ["python", "json", "orjson", "sentry"]
8+
"tags": ["python", "json", "orjson", "sentry"],
9+
"git": "https://github.com/codemod-com/codemod/tree/main/packages/codemods/python/orjson/json.load"
910
}
1011
}

packages/codemods/python/orjson/json.loads/.codemodrc.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
"$schema": "https://codemod-utils.s3.us-west-1.amazonaws.com/configuration_schema.json",
33
"version": "1.0.0",
44
"private": false,
5-
"name": "Converts json.loads to orjson.loads",
5+
"name": "python/orjson/json.loads",
66
"engine": "ast-grep",
77
"meta": {
8-
"tags": ["python", "json", "orjson", "sentry"]
8+
"tags": ["python", "json", "orjson", "sentry"],
9+
"git": "https://github.com/codemod-com/codemod/tree/main/packages/codemods/python/orjson/json.loads"
910
}
1011
}

packages/codemods/python/orjson/orjson.dumps-add-UTC_Z/.codemodrc.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
"$schema": "https://codemod-utils.s3.us-west-1.amazonaws.com/configuration_schema.json",
33
"version": "1.0.0",
44
"private": false,
5-
"name": "Add OPT_UTC_Z to orjson.dumps",
5+
"name": "python/orjson/dumps-add-UTC_Z",
66
"engine": "ast-grep",
77
"meta": {
8-
"tags": ["python", "json", "orjson", "sentry"]
8+
"tags": ["python", "json", "orjson", "sentry"],
9+
"git": "https://github.com/codemod-com/codemod/tree/main/packages/codemods/python/orjson/orjson.dumps-add-UTC_Z"
910
}
1011
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "https://codemod-utils.s3.us-west-1.amazonaws.com/configuration_schema.json",
3+
"name": "python/orjson/recipe",
4+
"version": "1.0.0",
5+
"private": false,
6+
"engine": "recipe",
7+
"names": [
8+
"python/orjson/json.dumps",
9+
"python/orjson/json.load",
10+
"python/orjson/json.loads",
11+
"python/orjson/dumps-add-UTC_Z",
12+
"python/orjson/sentry-import-replacement"
13+
],
14+
"meta": {
15+
"tags": ["migration", "python", "json", "orjson", "sentry"],
16+
"git": "https://github.com/codemod-com/codemod/tree/main/packages/codemods/python/orjson/recipe"
17+
}
18+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
This recipe is a set of codemods that will upgrade json to orjson in your python projects.
2+
3+
The recipe includes the following codemods:
4+
5+
- [python/orjson/json.dumps](https://github.com/codemod-com/codemod/tree/main/packages/codemods/python/orjson/json.dumps)
6+
- [python/orjson/json.load](https://github.com/codemod-com/codemod/tree/main/packages/codemods/python/orjson/json.load)
7+
- [python/orjson/json.loads](https://github.com/codemod-com/codemod/tree/main/packages/codemods/python/orjson/json.loads)
8+
- [python/orjson/dumps-add-UTC_Z](https://github.com/codemod-com/codemod/tree/main/packages/codemods/python/orjson/orjson.dumps-add-UTC_Z)
9+
- [python/orjson/sentry-import-replacement](https://github.com/codemod-com/codemod/tree/main/packages/codemods/python/orjson/sentry-import-replacement)
10+
11+
```python
12+
import orjson
13+
14+
raw_data = orjson.loads(dist_matched_artifact_index_release_file.file.getfile().read())
15+
orjson.dumps(content_as_json, option=orjson.OPT_UTC_Z)
16+
raw_data = orjson.loads(data)
17+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "@codemod-com/codemod-python-orjson-recipe",
3+
"files": ["./README.md", "./.codemodrc.json"],
4+
"type": "module"
5+
}

packages/codemods/python/orjson/sentry-import-replacement/.codemodrc.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
"$schema": "https://codemod-utils.s3.us-west-1.amazonaws.com/configuration_schema.json",
33
"version": "1.0.0",
44
"private": false,
5-
"name": "Converts Sentry json import to orjson",
5+
"name": "python/orjson/sentry-import-replacement",
66
"engine": "ast-grep",
77
"meta": {
8-
"tags": ["python", "json", "orjson", "sentry"]
8+
"tags": ["python", "json", "orjson", "sentry"],
9+
"git": "https://github.com/codemod-com/codemod/tree/main/packages/codemods/python/orjson/sentry-import-replacement"
910
}
1011
}

pnpm-lock.yaml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy