Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: 修改 model_config 的兼容适配 #18

Merged
merged 1 commit into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions codegen/templates/event.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ from typing import Union
from functools import cached_property
from typing_extensions import override

from nonebot.compat import PYDANTIC_V2, ConfigDict
{% for model in action.payload_types %}
from githubkit.versions.latest.models import {{ model }}
{% endfor %}
Expand Down Expand Up @@ -32,7 +33,10 @@ class {{ action.class_name }}(Event):
def get_message(self):
return self._message

class Config:
keep_untouched = (cached_property,)
if PYDANTIC_V2:
model_config = ConfigDict(ignored_types=(cached_property,))
else:
class Config:
keep_untouched = (cached_property,)

{% endif %}
4 changes: 4 additions & 0 deletions nonebot/adapters/github/event/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,9 @@
from .dependabot_alert_auto_dismissed import (
DependabotAlertAutoDismissed as DependabotAlertAutoDismissed,
)
from .secret_scanning_alert_validated import (
SecretScanningAlertValidated as SecretScanningAlertValidated,
)
from .sponsorship_pending_tier_change import (
SponsorshipPendingTierChange as SponsorshipPendingTierChange,
)
Expand Down Expand Up @@ -674,6 +677,7 @@
".secret_scanning_alert_reopened": ("SecretScanningAlertReopened",),
".secret_scanning_alert_resolved": ("SecretScanningAlertResolved",),
".secret_scanning_alert_revoked": ("SecretScanningAlertRevoked",),
".secret_scanning_alert_validated": ("SecretScanningAlertValidated",),
".secret_scanning_alert_location": ("SecretScanningAlertLocationCreated",),
".security_advisory_published": ("SecurityAdvisoryPublished",),
".security_advisory_updated": ("SecurityAdvisoryUpdated",),
Expand Down
1 change: 1 addition & 0 deletions nonebot/adapters/github/event/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@
"reopened": "SecretScanningAlertReopened",
"resolved": "SecretScanningAlertResolved",
"revoked": "SecretScanningAlertRevoked",
"validated": "SecretScanningAlertValidated",
},
"secret_scanning_alert_location": "SecretScanningAlertLocationCreated",
"security_advisory": {
Expand Down
9 changes: 7 additions & 2 deletions nonebot/adapters/github/event/commit_comment.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from functools import cached_property
from typing_extensions import override

from nonebot.compat import PYDANTIC_V2, ConfigDict
from githubkit.versions.latest.models import WebhookCommitCommentCreated

from ._base import Event
Expand All @@ -23,5 +24,9 @@ def _message(self):
def get_message(self):
return self._message

class Config:
keep_untouched = (cached_property,)
if PYDANTIC_V2:
model_config = ConfigDict(ignored_types=(cached_property,))
else:

class Config:
keep_untouched = (cached_property,)
9 changes: 7 additions & 2 deletions nonebot/adapters/github/event/issue_comment_created.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from functools import cached_property
from typing_extensions import override

from nonebot.compat import PYDANTIC_V2, ConfigDict
from githubkit.versions.latest.models import WebhookIssueCommentCreated

from ._base import Event
Expand All @@ -23,5 +24,9 @@ def _message(self):
def get_message(self):
return self._message

class Config:
keep_untouched = (cached_property,)
if PYDANTIC_V2:
model_config = ConfigDict(ignored_types=(cached_property,))
else:

class Config:
keep_untouched = (cached_property,)
9 changes: 7 additions & 2 deletions nonebot/adapters/github/event/issue_comment_deleted.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from functools import cached_property
from typing_extensions import override

from nonebot.compat import PYDANTIC_V2, ConfigDict
from githubkit.versions.latest.models import WebhookIssueCommentDeleted

from ._base import Event
Expand All @@ -19,5 +20,9 @@ def _message(self):
def get_message(self):
return self._message

class Config:
keep_untouched = (cached_property,)
if PYDANTIC_V2:
model_config = ConfigDict(ignored_types=(cached_property,))
else:

class Config:
keep_untouched = (cached_property,)
9 changes: 7 additions & 2 deletions nonebot/adapters/github/event/issue_comment_edited.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from functools import cached_property
from typing_extensions import override

from nonebot.compat import PYDANTIC_V2, ConfigDict
from githubkit.versions.latest.models import WebhookIssueCommentEdited

from ._base import Event
Expand All @@ -19,5 +20,9 @@ def _message(self):
def get_message(self):
return self._message

class Config:
keep_untouched = (cached_property,)
if PYDANTIC_V2:
model_config = ConfigDict(ignored_types=(cached_property,))
else:

class Config:
keep_untouched = (cached_property,)
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from functools import cached_property
from typing_extensions import override

from nonebot.compat import PYDANTIC_V2, ConfigDict
from githubkit.versions.latest.models import WebhookPullRequestReviewCommentCreated

from ._base import Event
Expand All @@ -23,5 +24,9 @@ def _message(self):
def get_message(self):
return self._message

class Config:
keep_untouched = (cached_property,)
if PYDANTIC_V2:
model_config = ConfigDict(ignored_types=(cached_property,))
else:

class Config:
keep_untouched = (cached_property,)
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from functools import cached_property
from typing_extensions import override

from nonebot.compat import PYDANTIC_V2, ConfigDict
from githubkit.versions.latest.models import WebhookPullRequestReviewCommentDeleted

from ._base import Event
Expand All @@ -19,5 +20,9 @@ def _message(self):
def get_message(self):
return self._message

class Config:
keep_untouched = (cached_property,)
if PYDANTIC_V2:
model_config = ConfigDict(ignored_types=(cached_property,))
else:

class Config:
keep_untouched = (cached_property,)
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from functools import cached_property
from typing_extensions import override

from nonebot.compat import PYDANTIC_V2, ConfigDict
from githubkit.versions.latest.models import WebhookPullRequestReviewCommentEdited

from ._base import Event
Expand All @@ -19,5 +20,9 @@ def _message(self):
def get_message(self):
return self._message

class Config:
keep_untouched = (cached_property,)
if PYDANTIC_V2:
model_config = ConfigDict(ignored_types=(cached_property,))
else:

class Config:
keep_untouched = (cached_property,)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from githubkit.versions.latest.models import WebhookSecretScanningAlertValidated

from ._base import Event


class SecretScanningAlertValidated(Event):

payload: WebhookSecretScanningAlertValidated