You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 13, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Oct 13, 2026. It is now read-only.
pylint: Instance of 'SubscriberClient' has no 'subscription_path' member #67
I think the issue is the typings, not necessarily that the method is not there (as it is). So I'd like to re-open this if possible, since the way this method is wired currently makes it incompatible with pylint.
@plamut@pradn Please mark this as a consideration for Pub/Sub v2.
@dinvlad We really should be compatible with pylint because of pylint's widespread usage 😞But for Version 1 of our library, this is probably not going to happen as it doesn't affect the functionality of the library. We are currently designing v2 - compatibility with third party tools will make into our considerations. Thank you again for raising it.
@dinvlad The classes in gapic/ directory are auto-generated based on the .proto definitions, including the SubscriberClient class, and there is a manual layer on top of that - the Client class from subscriber/client.py.
In order to avoid code duplication and to prevent the manual and generated client classes going out of sync, methods from the auto-generated class need to be automatically injected into the manual layer through the @_gapic.add_methods decorator. It's not surprising that such dynamic magic confuses the static linter. It's also not something that can be easily fixed in the library itself.
Of course, littering the source with numerous # pylint: disable=no-member comments is not appealing, but fortunately pylint can be configured to ignore that with the --generated-members setting. If you can stick to a common name for subscriber instances in your app, writing a regex that matches method invocations on them should do the trick.
@anguillanneuf just ran into the same issue and found out this thread....I was wondering if there is any update on a release of the v2 allowing the fix to work with pylint?
@g2github hey probably not a best practice but here is how I hacked this
topic_path = publisher.topic_path(project_id, topic_id)# pylint: disable=no-member
the pylint: disable=no-member allows you to override the error.
@dinvlad About the ways to fix the error or the v2 client?
AFAIK v2 client cannot be expected yet in the near/mid future, while IMHO the best way to silence false pylint errors is by leveraging the generated-members setting - better than littering the code with pylint: disable=no-member, unless there are only a few occurrences.
(I can ask about the v2 client for a more reliable answer, however)
@MiltiadisKoutsokeras Would you also mind to check with the tip of the main branch? (not released yet)
Recently, a considerable refactoring of the clients was merged - the hand-written classes now directly inherit from the generated classes, instead of dynamically injecting the generated methods into their namespace (static type checkers couldn't actually know that).
Simplifying the code should not confuse static type checkers anymore.
Edit: Sorry, was looking at the wrong PR. That particular PR is not merged yet, but at least there is a working solution out there. I will nudge the folks to review the changes.
Activity
dinvlad commentedon Apr 8, 2020
Might be related to googleapis/google-cloud-python#11865
anguillanneuf commentedon Apr 14, 2020
@dinvlad Thanks for your question.
subscription_pathis defined incloud/pubsub_v1/gapic/subscriber_client.py:python-pubsub/google/cloud/pubsub_v1/gapic/subscriber_client.py
Lines 109 to 116 in 21e761e
This method is being added in
cloud/pubsub_v1/subscriber/client.pyvia the decorator:python-pubsub/google/cloud/pubsub_v1/subscriber/client.py
Lines 43 to 44 in 21e761e
You should be able to see the method if you run
dir(subscriber). Does this help?dinvlad commentedon Apr 15, 2020
I think the issue is the typings, not necessarily that the method is not there (as it is). So I'd like to re-open this if possible, since the way this method is wired currently makes it incompatible with
pylint.dinvlad commentedon Apr 15, 2020
Specifically, unlike the
subscribe()method, thesubscription_path()method is not wired directly into https://github.com/googleapis/python-pubsub/blob/master/google/cloud/pubsub_v1/subscriber/client.py, but rather through the@_gapicannotation.. I'm not sure if this would be easy to fix?anguillanneuf commentedon Apr 15, 2020
@plamut @pradn Please mark this as a consideration for Pub/Sub v2.
@dinvlad We really should be compatible with
pylintbecause ofpylint's widespread usage 😞But for Version 1 of our library, this is probably not going to happen as it doesn't affect the functionality of the library. We are currently designing v2 - compatibility with third party tools will make into our considerations. Thank you again for raising it.dinvlad commentedon Apr 15, 2020
I see, thank you for explaining @anguillanneuf ! We'll keep this in mind.
As a workaround, we may probably switch to another linter for now - I think this library itself uses
pep8if I'm not mistaken?anguillanneuf commentedon Apr 15, 2020
No problem @dinvlad ! We use
nox, which complies toPEP8, see the Contributing Guide.plamut commentedon Apr 16, 2020
@dinvlad The classes in
gapic/directory are auto-generated based on the.protodefinitions, including theSubscriberClientclass, and there is a manual layer on top of that - theClientclass fromsubscriber/client.py.In order to avoid code duplication and to prevent the manual and generated client classes going out of sync, methods from the auto-generated class need to be automatically injected into the manual layer through the
@_gapic.add_methodsdecorator. It's not surprising that such dynamic magic confuses the static linter. It's also not something that can be easily fixed in the library itself.Of course, littering the source with numerous
# pylint: disable=no-membercomments is not appealing, but fortunatelypylintcan be configured to ignore that with the--generated-memberssetting. If you can stick to a common name for subscriber instances in your app, writing a regex that matches method invocations on them should do the trick.Would that be feasible for your case?
nicpreuss commentedon Sep 24, 2020
@anguillanneuf just ran into the same issue and found out this thread....I was wondering if there is any update on a release of the v2 allowing the fix to work with pylint?
anguillanneuf commentedon Sep 28, 2020
@nicpreuss On v2 there isn't. But thank you for raising it so it stays on our radar.
g2github commentedon Oct 22, 2020
I'm having this same issue, but am not clear what the "fix" is. How do I get past this error?
nicpreuss commentedon Oct 23, 2020
@g2github hey probably not a best practice but here is how I hacked this
topic_path = publisher.topic_path(project_id, topic_id)# pylint: disable=no-member
the pylint: disable=no-member allows you to override the error.
g2github commentedon Oct 23, 2020
thanks @nicpreuss
nicpreuss commentedon Oct 23, 2020
let me know if it works for you or if you find a better solution @g2github
g2github commentedon Oct 23, 2020
looks like i need # pylint: disable=no-member all over my code... how can this be possible?
dinvlad commentedon Feb 11, 2021
Any updates here?
plamut commentedon Feb 11, 2021
@dinvlad About the ways to fix the error or the v2 client?
AFAIK v2 client cannot be expected yet in the near/mid future, while IMHO the best way to silence false pylint errors is by leveraging the
generated-memberssetting - better than littering the code withpylint: disable=no-member, unless there are only a few occurrences.(I can ask about the v2 client for a more reliable answer, however)
dinvlad commentedon Feb 11, 2021
Thanks, that would be much appreciated!
plamut commentedon Feb 12, 2021
Update: The V2 client is currently still in the planning phase, and the earliest implementation is not expected before Q3/2021 (best case scenario).
MiltiadisKoutsokeras commentedon Jan 11, 2022
Hi all,
In case someone is reading this, the problem with pylint still persists using google-cloud-pubsub==2.9.0.
Instance of 'PublisherClient' has no 'topic_path' memberplamut commentedon Jan 11, 2022
@MiltiadisKoutsokeras Would you also mind to check with the tip of the
mainbranch? (not released yet)Recently, a considerable refactoring of the clients was merged - the hand-written classes now directly inherit from the generated classes, instead of dynamically injecting the generated methods into their namespace (static type checkers couldn't actually know that).
Simplifying the code should not confuse static type checkers anymore.
Edit: Sorry, was looking at the wrong PR. That particular PR is not merged yet, but at least there is a working solution out there. I will nudge the folks to review the changes.
adamwojt commentedon Apr 15, 2022
Same with pyright here with

google-cloud-pubsub==2.8.0.iamtodor commentedon Jan 23, 2023
@adamwojt in your case it's because of
topic_path()is@staticmethodBut treating it as static also does not work properly: