Title: fix: @_helpers.positional raises TypeError when decorating functions without default arguments · Issue #2844 · googleapis/google-api-python-client · GitHub
Open Graph Title: fix: @_helpers.positional raises TypeError when decorating functions without default arguments · Issue #2844 · googleapis/google-api-python-client
X Title: fix: @_helpers.positional raises TypeError when decorating functions without default arguments · Issue #2844 · googleapis/google-api-python-client
Description: Problem When @googleapiclient._helpers.positional is used as a bare decorator without arguments (e.g., @positional) on a callable that does not define default argument values (or takes no parameters), it raises TypeError: object of type ...
Open Graph Description: Problem When @googleapiclient._helpers.positional is used as a bare decorator without arguments (e.g., @positional) on a callable that does not define default argument values (or takes no parameter...
X Description: Problem When @googleapiclient._helpers.positional is used as a bare decorator without arguments (e.g., @positional) on a callable that does not define default argument values (or takes no parameter...
Opengraph URL: https://github.com/googleapis/google-api-python-client/issues/2844
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"fix: @_helpers.positional raises TypeError when decorating functions without default arguments","articleBody":"## Problem\nWhen `@googleapiclient._helpers.positional` is used as a bare decorator without arguments (e.g., `@positional`) on a callable that does not define default argument values (or takes no parameters), it raises `TypeError: object of type 'NoneType' has no len()` at function definition time.\n\n## Current Behavior\nIn `googleapiclient/_helpers.py`, `positional()` infers the maximum number of positional arguments when called without arguments:\n```python\n if isinstance(max_positional_args, int):\n return positional_decorator\n else:\n args, _, _, defaults, _, _, _ = inspect.getfullargspec(max_positional_args)\n return positional(len(args) - len(defaults))(max_positional_args)\n```\nWhen `max_positional_args` has no default parameters (or takes 0 parameters), `inspect.getfullargspec(max_positional_args).defaults` returns `None`.\nEvaluating `len(defaults)` then raises:\n`TypeError: object of type 'NoneType' has no len()`\n\n## Expected Behavior\nWhen `@positional` is used without arguments on a function without default parameters (such as `def func(a, b): ...`), `defaults` should default to an empty sequence (e.g., `len(defaults or ())`), correctly calculating `len(args) - 0 = len(args)` positional parameters instead of crashing with a `TypeError`.\n\n## Reproduction\n```python\nfrom googleapiclient import _helpers\n\n@_helpers.positional\ndef my_function(a, b):\n return a + b\n```\n\nResult:\n```\nTypeError: object of type 'NoneType' has no len()\n```\n\n## Technical Context\nIn `googleapiclient/_helpers.py`, replacing `len(defaults)` with `len(defaults or ())` safely treats `None` as 0 default arguments:\n```python\nargs, _, _, defaults, _, _, _ = inspect.getfullargspec(max_positional_args)\nreturn positional(len(args) - len(defaults or ()))(max_positional_args)\n```\n","author":{"url":"https://github.com/codeXsidd","@type":"Person","name":"codeXsidd"},"datePublished":"2026-10-22T10:35:11Z","url":"https://github.com/googleapis/google-api-python-client/issues/2844"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f41d5774-65eb-ced3-bd61-6f1a03c683d6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D7A6:D3271:38D91F:4EE107:6B008BCD |
| html-safe-nonce | 4d965dba878d7cb55745c8726a7b3c7c0f5d0d16322f8ee03f1387839f9ce047 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEN0E2OkQzMjcxOjM4RDkxRjo0RUUxMDc6NkIwMDhCQ0QiLCJ2aXNpdG9yX2lkIjoiMTY4MTA2MTYzMDM1NzU3MjU1NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 888b5581c1b6984c89772e70c30e54374d186e195cc16a103b854f942b50a14a |
| hovercard-subject-tag | issue:5977670225 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/google-api-python-client/2844/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b870207deaf2788529771caa6ba6def13651749d520407849f5f22b505d0a70a/googleapis/google-api-python-client/issues/2844 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b870207deaf2788529771caa6ba6def13651749d520407849f5f22b505d0a70a/googleapis/google-api-python-client/issues/2844 |
| og:image:alt | Problem When @googleapiclient._helpers.positional is used as a bare decorator without arguments (e.g., @positional) on a callable that does not define default argument values (or takes no parameter... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | codeXsidd |
| hostname | github.com |
| expected-hostname | github.com |
| None | c710a5cb5c47be60abfe6e8410436d409906979dbed614ef09f29c60f5535b08 |
| turbo-cache-control | no-preview |
| go-import | github.com/googleapis/google-api-python-client git https://github.com/googleapis/google-api-python-client.git |
| octolytics-dimension-user_id | 16785467 |
| octolytics-dimension-user_login | googleapis |
| octolytics-dimension-repository_id | 15749269 |
| octolytics-dimension-repository_nwo | googleapis/google-api-python-client |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 15749269 |
| octolytics-dimension-repository_network_root_nwo | googleapis/google-api-python-client |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | be616a2a6ec1c609d6e002896dff5352d5c5f28b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width