Skip to content

Commit 885d365

Browse files
authored
Feat/dev env cleanup (#167)
* build: Update pre-commit config versions and setup. Signed-off-by: Yurii Serhiichuk <[email protected]> * build: Migrate isort config to `pyproject` Signed-off-by: Yurii Serhiichuk <[email protected]> * style: Use recommended black-compatible flake8 options Signed-off-by: Yurii Serhiichuk <[email protected]> * build: Add standard pre-commit hooks. Signed-off-by: Yurii Serhiichuk <[email protected]> * docs: Add a note about this PR to the changelog. Signed-off-by: Yurii Serhiichuk <[email protected]> * docs: Cleanup docs, fix links. Add lins to respective tooling. Signed-off-by: Yurii Serhiichuk <[email protected]> * build: add dev-only dependencies. Signed-off-by: Yurii Serhiichuk <[email protected]> * style: reformat using new style/format configs Signed-off-by: Yurii Serhiichuk <[email protected]> * build: add pre-commit to dev dependencies Signed-off-by: Yurii Serhiichuk <[email protected]> * style: run pre-commit hooks on all the files Signed-off-by: Yurii Serhiichuk <[email protected]> * docs: Add dev status to the classifier. Signed-off-by: Yurii Serhiichuk <[email protected]> * docs: add missing links and dates for releases and PRs. Signed-off-by: Yurii Serhiichuk <[email protected]> * docs: Add latest PR to the changelog Signed-off-by: Yurii Serhiichuk <[email protected]> * ci: Add new maintainers Signed-off-by: Yurii Serhiichuk <[email protected]>
1 parent 8483e8e commit 885d365

24 files changed

+102
-111
lines changed

.isort.cfg

Lines changed: 0 additions & 4 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
repos:
2-
- repo: https://github.com/timothycrosley/isort/
3-
rev: 5.0.4
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.3.0
44
hooks:
5-
- id: isort
6-
- repo: https://github.com/psf/black
7-
rev: 19.10b0
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-toml
8+
- repo: https://github.com/pycqa/isort
9+
rev: 5.10.1
810
hooks:
9-
- id: black
10-
language_version: python3.9
11+
- id: isort
12+
args: [ "--profile", "black", "--filter-files" ]
13+
- repo: https://github.com/psf/black
14+
rev: 22.6.0
15+
hooks:
16+
- id: black
17+
language_version: python3.10

CHANGELOG.md

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Added
10+
- Added `.get` accessor for even properties ([#165])
11+
12+
### Changed
13+
- Code quality and styling tooling is unified and configs compatibility is ensured ([#167])
14+
915
## [1.3.0] — 2022-09-07
1016
### Added
1117
- Python 3.9 support ([#144])
@@ -17,11 +23,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1723
- Fixed typings issues ([#149])
1824
- The package redistributive ability by inlining required `pypi-packaging.py` functions ([#151])
1925

20-
## [1.2.0]
26+
## [1.2.0] — 2020-08-20
2127
### Added
2228
- Added GenericException, DataMarshallingError and DataUnmarshallingError ([#120])
2329

24-
## [1.1.0]
30+
## [1.1.0] — 2020-08-18
2531
### Changed
2632
- Changed from_http to now expect headers argument before data ([#110])
2733
- Renamed exception names ([#111])
@@ -32,12 +38,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3238
### Deprecated
3339
- Renamed to_binary_http and to_structured_http. ([#108])
3440

35-
## [1.0.1]
41+
## [1.0.1] — 2020-08-14
3642
### Added
3743
- CloudEvent exceptions and event type checking in http module ([#96])
3844
- CloudEvent equality override ([#98])
3945

40-
## [1.0.0]
46+
## [1.0.0] — 2020-08-11
4147
### Added
4248
- Update types and handle data_base64 structured ([#34])
4349
- Added a user friendly CloudEvent class with data validation ([#36])
@@ -51,7 +57,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5157
### Removed
5258
- Removed support for Cloudevents V0.2 and V0.1 ([#43])
5359

54-
## [0.3.0]
60+
## [0.3.0] — 2020-07-11
5561
### Added
5662
- Added Cloudevents V0.3 and V1 implementations ([#22])
5763
- Add helpful text to README ([#23])
@@ -92,7 +98,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9298
### Added
9399
- Initial release
94100

95-
[0.3.0]: https://github.com/cloudevents/sdk-python/compare/0.2.4...HEAD
101+
[1.3.0]: https://github.com/cloudevents/sdk-python/compare/1.2.0...1.3.0
102+
[1.2.0]: https://github.com/cloudevents/sdk-python/compare/1.1.0...1.2.0
103+
[1.1.0]: https://github.com/cloudevents/sdk-python/compare/1.0.1...1.1.0
104+
[1.0.1]: https://github.com/cloudevents/sdk-python/compare/1.0.0...1.0.1
105+
[1.0.0]: https://github.com/cloudevents/sdk-python/compare/0.3.0...1.0.0
106+
[0.3.0]: https://github.com/cloudevents/sdk-python/compare/0.2.4...0.3.0
96107
[0.2.4]: https://github.com/cloudevents/sdk-python/compare/0.2.3...0.2.4
97108
[0.2.3]: https://github.com/cloudevents/sdk-python/compare/0.2.2...0.2.3
98109
[0.2.2]: https://github.com/cloudevents/sdk-python/compare/0.2.1...0.2.2
@@ -126,4 +137,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
126137
[#110]: https://github.com/cloudevents/sdk-python/pull/110
127138
[#111]: https://github.com/cloudevents/sdk-python/pull/111
128139
[#119]: https://github.com/cloudevents/sdk-python/pull/119
129-
[#120]: https://github.com/cloudevents/sdk-python/pull/120
140+
[#120]: https://github.com/cloudevents/sdk-python/pull/120
141+
[#144]: https://github.com/cloudevents/sdk-python/pull/144
142+
[#149]: https://github.com/cloudevents/sdk-python/pull/149
143+
[#150]: https://github.com/cloudevents/sdk-python/pull/150
144+
[#151]: https://github.com/cloudevents/sdk-python/pull/151
145+
[#158]: https://github.com/cloudevents/sdk-python/pull/158
146+
[#159]: https://github.com/cloudevents/sdk-python/pull/159
147+
[#160]: https://github.com/cloudevents/sdk-python/pull/160
148+
[#165]: https://github.com/cloudevents/sdk-python/pull/165
149+
[#167]: https://github.com/cloudevents/sdk-python/pull/167

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ help:
1616
# Catch-all target: route all unknown targets to Sphinx using the new
1717
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
1818
%: Makefile
19-
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
19+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

OWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ admins:
22
- grant
33
- denismakogon
44
- cumason123
5+
- Klaudioz
6+
- xSAVIKx

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,19 +133,19 @@ the same API. It will use semantic versioning with following rules:
133133

134134
Each SDK may have its own unique processes, tooling and guidelines, common
135135
governance related material can be found in the
136-
[CloudEvents `community`](https://github.com/cloudevents/spec/tree/master/community)
136+
[CloudEvents `docs`](https://github.com/cloudevents/spec/tree/main/docs)
137137
directory. In particular, in there you will find information concerning
138138
how SDK projects are
139-
[managed](https://github.com/cloudevents/spec/blob/master/community/SDK-GOVERNANCE.md),
140-
[guidelines](https://github.com/cloudevents/spec/blob/master/community/SDK-maintainer-guidelines.md)
139+
[managed](https://github.com/cloudevents/spec/blob/main/docs/GOVERNANCE.md),
140+
[guidelines](https://github.com/cloudevents/spec/blob/main/docs/SDK-maintainer-guidelines.md)
141141
for how PR reviews and approval, and our
142-
[Code of Conduct](https://github.com/cloudevents/spec/blob/master/community/GOVERNANCE.md#additional-information)
142+
[Code of Conduct](https://github.com/cloudevents/spec/blob/main/docs/GOVERNANCE.md#additional-information)
143143
information.
144144

145145
## Maintenance
146146

147-
We use black and isort for autoformatting. We setup a tox environment to reformat
148-
the codebase.
147+
We use [black][black] and [isort][isort] for autoformatting. We set up a [tox][tox] environment
148+
to reformat the codebase.
149149

150150
e.g.
151151

@@ -155,3 +155,7 @@ tox -e reformat
155155
```
156156

157157
For information on releasing version bumps see [RELEASING.md](RELEASING.md)
158+
159+
[black]: https://black.readthedocs.io/
160+
[isort]: https://pycqa.github.io/isort/
161+
[tox]: https://tox.wiki/

cloudevents/http/event.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ class CloudEvent:
2626
Supports both binary and structured mode CloudEvents
2727
"""
2828

29-
def __init__(
30-
self, attributes: typing.Dict[str, str], data: typing.Any = None
31-
):
29+
def __init__(self, attributes: typing.Dict[str, str], data: typing.Any = None):
3230
"""
3331
Event Constructor
3432
:param attributes: a dict with cloudevent attributes. Minimally

cloudevents/http/event_type.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,4 @@ def is_structured(headers: typing.Dict[str, str]) -> bool:
2626
headers = {key.lower(): value for key, value in headers.items()}
2727
content_type = headers.get("content-type", "")
2828
structured_parser = structured.JSONHTTPCloudEventConverter()
29-
return structured_parser.can_read(
30-
content_type=content_type, headers=headers
31-
)
29+
return structured_parser.can_read(content_type=content_type, headers=headers)

cloudevents/sdk/converters/structured.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ class JSONHTTPCloudEventConverter(base.Converter):
2626
TYPE = "structured"
2727
MIME_TYPE = "application/cloudevents+json"
2828

29-
def can_read(
30-
self, content_type: str, headers: typing.Dict[str, str] = {}
31-
) -> bool:
29+
def can_read(self, content_type: str, headers: typing.Dict[str, str] = {}) -> bool:
3230
return (
3331
isinstance(content_type, str)
3432
and content_type.startswith(self.MIME_TYPE)

cloudevents/sdk/event/base.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,7 @@ def MarshalJSON(self, data_marshaller: types.MarshallerType) -> str:
206206
data = data_marshaller(data)
207207
except Exception as e:
208208
raise cloud_exceptions.DataMarshallerError(
209-
"Failed to marshall data with error: "
210-
f"{type(e).__name__}('{e}')"
209+
f"Failed to marshall data with error: {type(e).__name__}('{e}')"
211210
)
212211
if isinstance(data, (bytes, bytes, memoryview)):
213212
props["data_base64"] = base64.b64encode(data).decode("ascii")
@@ -256,9 +255,7 @@ def UnmarshalBinary(
256255
body: typing.Union[bytes, str],
257256
data_unmarshaller: types.UnmarshallerType,
258257
):
259-
required_binary_fields = {
260-
f"ce-{field}" for field in self._ce_required_fields
261-
}
258+
required_binary_fields = {f"ce-{field}" for field in self._ce_required_fields}
262259
missing_fields = required_binary_fields - headers.keys()
263260

264261
if len(missing_fields) > 0:
@@ -277,8 +274,7 @@ def UnmarshalBinary(
277274
raw_ce = data_unmarshaller(body)
278275
except Exception as e:
279276
raise cloud_exceptions.DataUnmarshallerError(
280-
"Failed to unmarshall data with error: "
281-
f"{type(e).__name__}('{e}')"
277+
f"Failed to unmarshall data with error: {type(e).__name__}('{e}')"
282278
)
283279
self.Set("data", raw_ce)
284280

@@ -304,8 +300,7 @@ def MarshalBinary(
304300
data = data_marshaller(data)
305301
except Exception as e:
306302
raise cloud_exceptions.DataMarshallerError(
307-
"Failed to marshall data with error: "
308-
f"{type(e).__name__}('{e}')"
303+
f"Failed to marshall data with error: {type(e).__name__}('{e}')"
309304
)
310305
if isinstance(data, str): # Convenience method for json.dumps
311306
data = data.encode("utf-8")

0 commit comments

Comments
 (0)