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: add warning about python sdk login_user breaking change in 21.4.0 #579

Merged
merged 1 commit into from
Apr 13, 2021
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
15 changes: 15 additions & 0 deletions packages/sdk-codegen/src/python.gen.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ DelimSequence = model.DelimSequence
# NOTE: Do not edit this file generated by Looker SDK Codegen
import datetime
from typing import Any, MutableMapping, Optional, Sequence, Union
import warnings

from . import models
from looker_sdk.rtl import api_methods
Expand Down Expand Up @@ -409,6 +410,20 @@ return response`
transport_options=transport_options
)
assert isinstance(response, list)
return response`
const actual = gen.httpCall(indent, method)
expect(actual).toEqual(expected)
})
it('assert login_user has a warning', () => {
const method = apiTestModel.methods.login_user
const expected = `warnings.warn("login_user behavior changed significantly in 21.4.0. See https://git.io/JOtH1")
response = self.post(
f"/login/{user_id}",
models.AccessToken,
query_params={"associative": associative},
transport_options=transport_options
)
assert isinstance(response, models.AccessToken)
return response`
const actual = gen.httpCall(indent, method)
expect(actual).toEqual(expected)
Expand Down
12 changes: 9 additions & 3 deletions packages/sdk-codegen/src/python.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export class PythonGen extends CodeGen {
# ${this.warnEditing()}
import datetime
from typing import Any, MutableMapping, Optional, Sequence, Union
import warnings

from . import models
from ${this.packagePath}.rtl import api_methods
Expand Down Expand Up @@ -401,15 +402,20 @@ ${this.hooks.join('\n')}
}
result = this.argFill(result, returnType)
result = this.argFill(result, `f"${method.endpoint}"`)
return result
return this.bumper(indent) + result
}

httpCall(indent: string, method: IMethod) {
const bump = indent + this.indentStr
const args = this.httpArgs(bump, method)
const methodCall = `${indent}response = ${this.it(
let methodCall = `${indent}response = ${this.it(
method.httpMethod.toLowerCase()
)}`
if (method.name === 'login_user') {
methodCall =
`${indent}warnings.warn("login_user behavior changed significantly ` +
`in 21.4.0. See https://git.io/JOtH1")\n${methodCall}`
}
Comment on lines +414 to +418
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Want to create an issue to remove this after 3 - 6 months?

let assertTypeName = this.methodReturnType(method)
switch (method.type.className) {
case 'ArrayType':
Expand All @@ -432,7 +438,7 @@ ${this.hooks.join('\n')}
const returnStmt = `${indent}return response`
return (
`${methodCall}(\n` +
`${bump.repeat(3)}${args}\n` +
`${this.bumper(indent)}${args}\n` +
`${indent})\n` +
`${assertion}\n` +
`${returnStmt}`
Expand Down
4 changes: 4 additions & 0 deletions python/looker_sdk/sdk/api31/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
# NOTE: Do not edit this file generated by Looker SDK Codegen for Looker 21.4 API 3.1
import datetime
from typing import Any, MutableMapping, Optional, Sequence, Union
import warnings

from . import models
from looker_sdk.rtl import api_methods
Expand Down Expand Up @@ -111,6 +112,9 @@ def login_user(
transport_options: Optional[transport.TransportOptions] = None,
) -> models.AccessToken:
"""Login user"""
warnings.warn(
"login_user behavior changed significantly in 21.4.0. See https://git.io/JOtH1"
)
response = self.post(
f"/login/{user_id}",
models.AccessToken,
Expand Down
4 changes: 4 additions & 0 deletions python/looker_sdk/sdk/api40/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
# NOTE: Do not edit this file generated by Looker SDK Codegen for Looker 21.4 API 4.0
import datetime
from typing import Any, MutableMapping, Optional, Sequence, Union
import warnings

from . import models
from looker_sdk.rtl import api_methods
Expand Down Expand Up @@ -111,6 +112,9 @@ def login_user(
transport_options: Optional[transport.TransportOptions] = None,
) -> models.AccessToken:
"""Login user"""
warnings.warn(
"login_user behavior changed significantly in 21.4.0. See https://git.io/JOtH1"
)
response = self.post(
f"/login/{user_id}",
models.AccessToken,
Expand Down
1 change: 1 addition & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
},
"python": {
"release-type": "python",
"release-as": "21.4.1",
"draft": true,
"package-name": "looker_sdk"
}
Expand Down