Skip to content

Commit a318ca1

Browse files
authored
Merge pull request #47 from hit9/compat-py311
Compat Python 3.11
2 parents e815254 + fc600e1 commit a318ca1

File tree

15 files changed

+41
-30
lines changed

15 files changed

+41
-30
lines changed

.github/workflows/bench.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ jobs:
1717
strategy:
1818
matrix:
1919
os: [ubuntu-20.04, ubuntu-18.04, macos-latest]
20-
python: ["3.10"]
21-
go: ["1.18"]
20+
python: ["3.11"]
21+
go: ["1.19"]
2222

2323
runs-on: ${{ matrix.os }}
2424

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
matrix:
1919
os: [ubuntu-18.04]
20-
python: [3.7, 3.8, "3.10"]
20+
python: [3.7, 3.8, "3.10", "3.11"]
2121
go: ["1.19", "1.16"]
2222

2323
runs-on: ${{ matrix.os }}
@@ -47,24 +47,24 @@ jobs:
4747
run: |
4848
pip install -r compiler/requirements_dev.txt
4949
pip install -r lib/py/requirements_dev.txt
50+
if: "matrix.python == '3.11'"
5051

5152
- name: Install tests requirements
5253
run: |
5354
pip install -r tests/requirements_tests.txt
5455
55-
5656
- name: Install clang-format 11.0
5757
run: |
5858
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
5959
sudo apt-add-repository 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main'
6060
sudo apt update
6161
sudo apt-get install clang-format-11 -y
62-
if: "matrix.python == '3.10'"
62+
if: "matrix.python == '3.11'"
6363

6464
- name: Run lints
6565
run: |
6666
make lint CLANG_FORMAT=clang-format-11
67-
if: "matrix.python == '3.10'"
67+
if: "matrix.python == '3.11'"
6868

6969
- name: Run tests
7070
run: |

changes.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
.. currentmodule:: bitproto
22

3+
Version 1.0.1
4+
-------------
5+
6+
.. _version-1.0.1
7+
8+
- Add support for Python 3.11
9+
310
Version 1.0.0
411
-------------
512

compiler/bitproto/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
99
"""
1010

11-
__version__ = "1.0.0"
11+
__version__ = "1.0.1"
1212
__description__ = "bit level data interchange format."

compiler/bitproto/_ast.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ class Array(CompositeType, ExtensibleType):
761761
Constraint: Capacity of array should be smaller than 65536.
762762
"""
763763

764-
element_type: Type = _TYPE_MISSING
764+
element_type: Type = dataclass_field(default_factory=lambda: _TYPE_MISSING)
765765
cap: int = 0
766766

767767
@classmethod
@@ -817,7 +817,7 @@ class Alias(Type, BoundDefinition):
817817
:param type: The referenced type.
818818
"""
819819

820-
type: Type = _TYPE_MISSING
820+
type: Type = dataclass_field(default_factory=lambda: _TYPE_MISSING)
821821

822822
def __repr__(self) -> str:
823823
return f"<alias {self.name}>"
@@ -884,7 +884,7 @@ class Enum(BoundScope, SingleType):
884884
Enum in bitproto constraints to uint type.
885885
"""
886886

887-
type: Uint = _UINT_MISSING
887+
type: Uint = dataclass_field(default_factory=lambda: _UINT_MISSING)
888888

889889
def __repr__(self) -> str:
890890
return f"<enum {self.name}>"
@@ -934,7 +934,7 @@ def validate_enum_field_on_push(self, field: EnumField) -> None:
934934
@frozen
935935
@dataclass
936936
class MessageField(Field):
937-
type: Type = Type()
937+
type: Type = dataclass_field(default_factory=Type)
938938
number: int = 0
939939

940940
def __repr__(self) -> str:

compiler/bitproto/_main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ def main(
137137
fatal(str(error))
138138

139139
# Lint
140+
lint_warnings = 0
140141
if not disable_linter:
141142
lint_warnings = lint(proto)
142143

compiler/bitproto/errors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"""
1717

1818
from dataclasses import dataclass
19-
from typing import TYPE_CHECKING, Any, ClassVar, Optional, Type as T, TypeVar
19+
from typing import TYPE_CHECKING, Any, Optional, Type as T, TypeVar
2020

2121
from bitproto.utils import Color, colored, overridable, override, write_stderr
2222

@@ -40,7 +40,7 @@ def format_default_description(self) -> str:
4040

4141
@overridable
4242
def _message_prefix(self) -> str:
43-
pass
43+
raise NotImplementedError
4444

4545
def __str__(self) -> str:
4646
description = self.description

compiler/bitproto/linter.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
"""
77

88
from abc import abstractmethod
9-
from dataclasses import dataclass
10-
from typing import Callable, Generic, List, Optional, Tuple, Type as T, TypeVar
9+
from typing import Generic, List, Optional, Tuple, Type as T, TypeVar
1110

1211
from bitproto._ast import (
1312
Alias,
@@ -18,7 +17,6 @@
1817
EnumField,
1918
Message,
2019
MessageField,
21-
Node,
2220
Proto,
2321
)
2422
from bitproto.errors import (
@@ -31,7 +29,6 @@
3129
LintWarning,
3230
MessageFieldNameNotSnake,
3331
MessageNameNotPascal,
34-
Warning,
3532
warning,
3633
)
3734
from bitproto.utils import pascal_case, snake_case

compiler/bitproto/options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"""
77

88
from dataclasses import dataclass
9-
from typing import Callable, Optional, Tuple, Union, cast
9+
from typing import Callable, Optional, Tuple, Union
1010

1111
Value = Union[bool, int, str]
1212
Validator = Callable[..., bool]

compiler/bitproto/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
Any,
99
Callable,
1010
List,
11+
NoReturn,
1112
Optional,
1213
Type as T,
1314
TypeVar,
@@ -126,7 +127,7 @@ def __get__(self, obj: None, cls: T[I]) -> "cached_property":
126127
...
127128

128129
@overload
129-
def __get__(self, obj: I, cls: T[I]) -> O:
130+
def __get__(self, obj: I, cls: T[I]) -> O: # type: ignore
130131
...
131132

132133
def __get__(self, obj: Optional[I], cls: T[I]) -> Union["cached_property", O]:
@@ -292,7 +293,7 @@ def write_stderr(s: str) -> None:
292293
sys.stderr.write(s + "\n")
293294

294295

295-
def fatal(s: str = "", code: int = 1) -> None:
296+
def fatal(s: str = "", code: int = 1) -> NoReturn:
296297
"""Exit the whole program with given code and message."""
297298
if s:
298299
write_stderr(s)

compiler/requirements_dev.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
black>=22.0,<=23.0
2-
isort>=5.7.0,<=6.0.0
3-
mypy>=0.790,<=0.800
4-
mypy-extensions>=0.4.3,<=0.5.0
5-
pyinstaller>=4.2,<=5.0
1+
black>=22.0
2+
isort>=5.7.0
3+
mypy>=0.790
4+
mypy-extensions>=0.4.3
5+
pyinstaller>=4.2
66
twine>=3.4.2

compiler/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,6 @@
7272
"Programming Language :: Python :: 3.8",
7373
"Programming Language :: Python :: 3.9",
7474
"Programming Language :: Python :: 3.10",
75+
"Programming Language :: Python :: 3.11",
7576
],
7677
)

lib/c/bitproto.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
extern "C" {
2323
#endif
2424

25+
#define __BITPROTO_VERSION__ "1.0.1"
26+
2527
////////////////////
2628
// Macros
2729
////////////////////

lib/py/requirements_dev.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
black>=22.0,<=23.0
2-
isort>=5.7.0,<=6.0.0
3-
mypy>=0.790,<=0.800
4-
mypy-extensions>=0.4.3,<=0.5.0
1+
black>=22.0
2+
isort>=5.7.0
3+
mypy>=0.790
4+
mypy-extensions>=0.4.3

lib/py/setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="bitprotolib",
5-
version="1.0.0",
5+
version="1.0.1",
66
url="https://github.com/hit9/bitproto",
77
author="Chao Wang",
88
author_email="hit9@icloud.com",
@@ -22,5 +22,7 @@
2222
"Programming Language :: Python :: 3.7",
2323
"Programming Language :: Python :: 3.8",
2424
"Programming Language :: Python :: 3.9",
25+
"Programming Language :: Python :: 3.10",
26+
"Programming Language :: Python :: 3.11",
2527
],
2628
)

0 commit comments

Comments
 (0)