-
Notifications
You must be signed in to change notification settings - Fork 549
ref: Introduce linter for proper naming conventions #636
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,18 @@ | ||
[flake8] | ||
ignore = | ||
E203, E266, E501, W503, E402, E731, C901, B950, B011, | ||
B014 // does not apply to Python 2 | ||
E203, // Handled by black (Whitespace before ':' -- handled by black) | ||
E266, // Handled by black (Too many leading '#' for block comment) | ||
E501, // Handled by black (Line too long) | ||
W503, // Handled by black (Line break occured before a binary operator) | ||
E402, // Sometimes not possible due to execution order (Module level import is not at top of file) | ||
E731, // I don't care (Do not assign a lambda expression, use a def) | ||
C901, // I don't care (Function is too complex) | ||
B950, // Handled by black (Line too long by flake8-bugbear) | ||
B011, // I don't care (Do not call assert False) | ||
B014, // does not apply to Python 2 (redundant exception types by flake8-bugbear) | ||
N812, // I don't care (Lowercase imported as non-lowercase by pep8-naming) | ||
N804 // is a worse version of and conflicts with B902 (first argument of a classmethod should be named cls) | ||
max-line-length = 80 | ||
max-complexity = 18 | ||
select = B,C,E,F,W,T4,B9 | ||
select = N,B,C,E,F,W,T4,B9 | ||
exclude=checkouts,lol*,.tox |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ flake8 | |
flake8-import-order | ||
mypy==0.761 | ||
flake8-bugbear>=19.8.0 | ||
pep8-naming |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,11 +29,11 @@ def _set_app_properties(): | |
""" | ||
from pyspark import SparkContext | ||
|
||
sparkContext = SparkContext._active_spark_context | ||
if sparkContext: | ||
sparkContext.setLocalProperty("sentry_app_name", sparkContext.appName) | ||
sparkContext.setLocalProperty( | ||
"sentry_application_id", sparkContext.applicationId | ||
spark_context = SparkContext._active_spark_context | ||
if spark_context: | ||
spark_context.setLocalProperty("sentry_app_name", spark_context.appName) | ||
spark_context.setLocalProperty( | ||
"sentry_application_id", spark_context.applicationId | ||
) | ||
|
||
|
||
|
@@ -106,99 +106,101 @@ def process_event(event, hint): | |
|
||
|
||
class SparkListener(object): | ||
def onApplicationEnd(self, applicationEnd): | ||
def onApplicationEnd(self, applicationEnd): # noqa: N802,N803 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe apply this to the whole class or module/file? Also could we have a note like "# noqa: ...; ignore camelCase in methods names and attributes because this code is inherited from somewhere..." There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure how to specify it on a class level. I would like to avoid doing it on a module level for sure asssuming we do not restructure the modules. |
||
# type: (Any) -> None | ||
pass | ||
|
||
def onApplicationStart(self, applicationStart): | ||
def onApplicationStart(self, applicationStart): # noqa: N802,N803 | ||
# type: (Any) -> None | ||
pass | ||
|
||
def onBlockManagerAdded(self, blockManagerAdded): | ||
def onBlockManagerAdded(self, blockManagerAdded): # noqa: N802,N803 | ||
# type: (Any) -> None | ||
pass | ||
|
||
def onBlockManagerRemoved(self, blockManagerRemoved): | ||
def onBlockManagerRemoved(self, blockManagerRemoved): # noqa: N802,N803 | ||
# type: (Any) -> None | ||
pass | ||
|
||
def onBlockUpdated(self, blockUpdated): | ||
def onBlockUpdated(self, blockUpdated): # noqa: N802,N803 | ||
# type: (Any) -> None | ||
pass | ||
|
||
def onEnvironmentUpdate(self, environmentUpdate): | ||
def onEnvironmentUpdate(self, environmentUpdate): # noqa: N802,N803 | ||
# type: (Any) -> None | ||
pass | ||
|
||
def onExecutorAdded(self, executorAdded): | ||
def onExecutorAdded(self, executorAdded): # noqa: N802,N803 | ||
# type: (Any) -> None | ||
pass | ||
|
||
def onExecutorBlacklisted(self, executorBlacklisted): | ||
def onExecutorBlacklisted(self, executorBlacklisted): # noqa: N802,N803 | ||
# type: (Any) -> None | ||
pass | ||
|
||
def onExecutorBlacklistedForStage(self, executorBlacklistedForStage): | ||
def onExecutorBlacklistedForStage( # noqa: N802 | ||
self, executorBlacklistedForStage # noqa: N803 | ||
): | ||
# type: (Any) -> None | ||
pass | ||
|
||
def onExecutorMetricsUpdate(self, executorMetricsUpdate): | ||
def onExecutorMetricsUpdate(self, executorMetricsUpdate): # noqa: N802,N803 | ||
# type: (Any) -> None | ||
pass | ||
|
||
def onExecutorRemoved(self, executorRemoved): | ||
def onExecutorRemoved(self, executorRemoved): # noqa: N802,N803 | ||
# type: (Any) -> None | ||
pass | ||
|
||
def onJobEnd(self, jobEnd): | ||
def onJobEnd(self, jobEnd): # noqa: N802,N803 | ||
# type: (Any) -> None | ||
pass | ||
|
||
def onJobStart(self, jobStart): | ||
def onJobStart(self, jobStart): # noqa: N802,N803 | ||
# type: (Any) -> None | ||
pass | ||
|
||
def onNodeBlacklisted(self, nodeBlacklisted): | ||
def onNodeBlacklisted(self, nodeBlacklisted): # noqa: N802,N803 | ||
# type: (Any) -> None | ||
pass | ||
|
||
def onNodeBlacklistedForStage(self, nodeBlacklistedForStage): | ||
def onNodeBlacklistedForStage(self, nodeBlacklistedForStage): # noqa: N802,N803 | ||
# type: (Any) -> None | ||
pass | ||
|
||
def onNodeUnblacklisted(self, nodeUnblacklisted): | ||
def onNodeUnblacklisted(self, nodeUnblacklisted): # noqa: N802,N803 | ||
# type: (Any) -> None | ||
pass | ||
|
||
def onOtherEvent(self, event): | ||
def onOtherEvent(self, event): # noqa: N802,N803 | ||
# type: (Any) -> None | ||
pass | ||
|
||
def onSpeculativeTaskSubmitted(self, speculativeTask): | ||
def onSpeculativeTaskSubmitted(self, speculativeTask): # noqa: N802,N803 | ||
# type: (Any) -> None | ||
pass | ||
|
||
def onStageCompleted(self, stageCompleted): | ||
def onStageCompleted(self, stageCompleted): # noqa: N802,N803 | ||
# type: (Any) -> None | ||
pass | ||
|
||
def onStageSubmitted(self, stageSubmitted): | ||
def onStageSubmitted(self, stageSubmitted): # noqa: N802,N803 | ||
# type: (Any) -> None | ||
pass | ||
|
||
def onTaskEnd(self, taskEnd): | ||
def onTaskEnd(self, taskEnd): # noqa: N802,N803 | ||
# type: (Any) -> None | ||
pass | ||
|
||
def onTaskGettingResult(self, taskGettingResult): | ||
def onTaskGettingResult(self, taskGettingResult): # noqa: N802,N803 | ||
# type: (Any) -> None | ||
pass | ||
|
||
def onTaskStart(self, taskStart): | ||
def onTaskStart(self, taskStart): # noqa: N802,N803 | ||
# type: (Any) -> None | ||
pass | ||
|
||
def onUnpersistRDD(self, unpersistRDD): | ||
def onUnpersistRDD(self, unpersistRDD): # noqa: N802,N803 | ||
# type: (Any) -> None | ||
pass | ||
|
||
|
@@ -211,13 +213,13 @@ def __init__(self): | |
# type: () -> None | ||
self.hub = Hub.current | ||
|
||
def onJobStart(self, jobStart): | ||
def onJobStart(self, jobStart): # noqa: N802,N803 | ||
# type: (Any) -> None | ||
message = "Job {} Started".format(jobStart.jobId()) | ||
self.hub.add_breadcrumb(level="info", message=message) | ||
_set_app_properties() | ||
|
||
def onJobEnd(self, jobEnd): | ||
def onJobEnd(self, jobEnd): # noqa: N802,N803 | ||
# type: (Any) -> None | ||
level = "" | ||
message = "" | ||
|
@@ -232,30 +234,30 @@ def onJobEnd(self, jobEnd): | |
|
||
self.hub.add_breadcrumb(level=level, message=message, data=data) | ||
|
||
def onStageSubmitted(self, stageSubmitted): | ||
def onStageSubmitted(self, stageSubmitted): # noqa: N802,N803 | ||
# type: (Any) -> None | ||
stageInfo = stageSubmitted.stageInfo() | ||
message = "Stage {} Submitted".format(stageInfo.stageId()) | ||
data = {"attemptId": stageInfo.attemptId(), "name": stageInfo.name()} | ||
stage_info = stageSubmitted.stageInfo() | ||
message = "Stage {} Submitted".format(stage_info.stageId()) | ||
data = {"attemptId": stage_info.attemptId(), "name": stage_info.name()} | ||
self.hub.add_breadcrumb(level="info", message=message, data=data) | ||
_set_app_properties() | ||
|
||
def onStageCompleted(self, stageCompleted): | ||
def onStageCompleted(self, stageCompleted): # noqa: N802,N803 | ||
# type: (Any) -> None | ||
from py4j.protocol import Py4JJavaError # type: ignore | ||
|
||
stageInfo = stageCompleted.stageInfo() | ||
stage_info = stageCompleted.stageInfo() | ||
message = "" | ||
level = "" | ||
data = {"attemptId": stageInfo.attemptId(), "name": stageInfo.name()} | ||
data = {"attemptId": stage_info.attemptId(), "name": stage_info.name()} | ||
|
||
# Have to Try Except because stageInfo.failureReason() is typed with Scala Option | ||
try: | ||
data["reason"] = stageInfo.failureReason().get() | ||
message = "Stage {} Failed".format(stageInfo.stageId()) | ||
data["reason"] = stage_info.failureReason().get() | ||
message = "Stage {} Failed".format(stage_info.stageId()) | ||
level = "warning" | ||
except Py4JJavaError: | ||
message = "Stage {} Completed".format(stageInfo.stageId()) | ||
message = "Stage {} Completed".format(stage_info.stageId()) | ||
level = "info" | ||
|
||
self.hub.add_breadcrumb(level=level, message=message, data=data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might not be remembering well, but I thought
class metaclass
was common practice?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I honestly don't know. Are you saying that metaclasses are supposed to be snakecase?