codecov[bot]: # [Codecov](https://codecov.io/gh/youknowone/ring/pull/80?src=pr&el=h1) Report
> Merging [#80](https://codecov.io/gh/youknowone/ring/pull/80?src=pr&el=desc) into [master](https://codecov.io/gh/youknowone/ring/commit/33fd69eed378616ed031a0560e14007b6d43008a?src=pr&el=desc) will **decrease** coverage by `1.27%`.
> The diff coverage is `100%`.


```diff
@@            Coverage Diff             @@
##           master      #80      +/-   ##
==========================================
- Coverage   97.88%   96.61%   -1.27%     
==========================================
  Files          13       13              
  Lines        1084     1090       +6     
==========================================
- Hits         1061     1053       -8     
- Misses         23       37      +14
```




diff --git a/ring/wire.py b/ring/wire.py
index 069ec40..078cb04 100644
--- a/ring/wire.py
+++ b/ring/wire.py
@@ -56,10 +56,17 @@ class Wire(object):
 
         _shared_attrs = {'attrs': {}}
 
-        if is_method(cwrapper) or is_classmethod(cwrapper):
+        c_is_method = is_method(cwrapper)
+        c_is_classmethod = is_classmethod(cwrapper)
+        if c_is_method or c_is_classmethod:
             @WiredProperty
             def _w(self):
-                wrapper_name = '__wrapper_' + cwrapper.code.co_name
+                wrapper_name_parts = ['__wire_', cwrapper.code.co_name]
+                if c_is_classmethod:
+                    self_cls = self if type(self) == type else type(self)  # fragile
+                    wrapper_name_parts.extend(('_', self_cls.__name__))
+                    self = self_cls
+                wrapper_name = ''.join(wrapper_name_parts)
                 wrapper = getattr(self, wrapper_name, None)
                 if wrapper is None:
                     _wrapper = cls(cwrapper, _shared_attrs)

[BUG] It doesn't work for classmethod very well
~Even if "cls" is different in classmethod, Ring doesn't distinguish them~

Now cls is correctly passed to classmethod, but not about subclasses.

Related test: https://github.com/youknowone/ring/blob/master/tests/test_key.py#L64
diff --git a/tests/test_key.py b/tests/test_key.py
index bf08f0a..5f87fe4 100644
--- a/tests/test_key.py
+++ b/tests/test_key.py
@@ -1,3 +1,4 @@
+import six
 import ring
 from ring.key import FormatKey, CallableKey
 
@@ -61,7 +62,22 @@ def test_classmethod_key():
         pass
 
     assert A.f.key().endswith('.A.f:A'), A.f.key()
-    # assert B.f.key().endswith('.A.f:B'), B.f.key() -- TODO
+    if six.PY2:
+        assert B.f.key().endswith('.B.f:B'), B.f.key()
+    else:
+        assert B.f.key().endswith('.A.f:B'), B.f.key()
+
+    a = A()
+    b = B()
+
+    assert a.f.key().endswith('.A.f:A'), a.f.key()
+    if six.PY2:
+        assert b.f.key().endswith('.B.f:B'), b.f.key()
+    else:
+        assert b.f.key().endswith('.A.f:B'), b.f.key()
+
+    assert A.f.key() == a.f.key()
+    assert B.f.key() == b.f.key()
 
 
 def test_unexisting_ring_key():

pip install -e .[dev]
parse_log_pytest
pytest
pytest pytest-cov mock patch pymemcache redis
apt-get update apt-get install -y gcc libmemcached-dev memcached redis-server
3.6
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
alabaster==0.7.13
asgiref==3.4.1
async-timeout==4.0.2
attrs @ file:///opt/conda/conda-bld/attrs_1642510447205/work
Babel==2.11.0
certifi==2021.5.30
charset-normalizer==2.0.12
coverage==6.2
diskcache==5.6.3
Django==3.2.25
docutils==0.18.1
idna==3.10
imagesize==1.4.1
importlib-metadata @ file:///tmp/build/80754af9/importlib-metadata_1631916693255/work
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
Jinja2==3.0.3
MarkupSafe==2.0.1
mock==5.2.0
more-itertools @ file:///tmp/build/80754af9/more-itertools_1637733554872/work
packaging @ file:///tmp/build/80754af9/packaging_1637314298585/work
patch==1.16
pluggy @ file:///tmp/build/80754af9/pluggy_1615976315926/work
prettyexc==0.6.0
py @ file:///opt/conda/conda-bld/py_1644396412707/work
Pygments==2.14.0
pymemcache==3.5.2
pyparsing @ file:///tmp/build/80754af9/pyparsing_1635766073266/work
pytest==6.2.4
pytest-cov==4.0.0
pytest-lazy-fixture==0.6.3
pytz==2025.2
redis==4.3.6
requests==2.27.1
-e git+https://github.com/youknowone/ring.git@33fd69eed378616ed031a0560e14007b6d43008a#egg=ring
six==1.17.0
snowballstemmer==2.2.0
Sphinx==5.3.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
sqlparse==0.4.4
toml @ file:///tmp/build/80754af9/toml_1616166611790/work
tomli==1.2.3
typing_extensions @ file:///opt/conda/conda-bld/typing_extensions_1647553014482/work
urllib3==1.26.20
zipp @ file:///tmp/build/80754af9/zipp_1633618647012/work

name: ring
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - attrs=21.4.0=pyhd3eb1b0_0
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - importlib-metadata=4.8.1=py36h06a4308_0
  - importlib_metadata=4.8.1=hd3eb1b0_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - more-itertools=8.12.0=pyhd3eb1b0_0
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - packaging=21.3=pyhd3eb1b0_0
  - pip=21.2.2=py36h06a4308_0
  - pluggy=0.13.1=py36h06a4308_0
  - py=1.11.0=pyhd3eb1b0_0
  - pyparsing=3.0.4=pyhd3eb1b0_0
  - pytest=6.2.4=py36h06a4308_2
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - toml=0.10.2=pyhd3eb1b0_0
  - typing_extensions=4.1.1=pyh06a4308_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zipp=3.6.0=pyhd3eb1b0_0
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - alabaster==0.7.13
      - asgiref==3.4.1
      - async-timeout==4.0.2
      - babel==2.11.0
      - charset-normalizer==2.0.12
      - coverage==6.2
      - diskcache==5.6.3
      - django==3.2.25
      - docutils==0.18.1
      - idna==3.10
      - imagesize==1.4.1
      - jinja2==3.0.3
      - markupsafe==2.0.1
      - mock==5.2.0
      - patch==1.16
      - prettyexc==0.6.0
      - pygments==2.14.0
      - pymemcache==3.5.2
      - pytest-cov==4.0.0
      - pytest-lazy-fixture==0.6.3
      - pytz==2025.2
      - redis==4.3.6
      - requests==2.27.1
      - six==1.17.0
      - snowballstemmer==2.2.0
      - sphinx==5.3.0
      - sphinxcontrib-applehelp==1.0.2
      - sphinxcontrib-devhelp==1.0.2
      - sphinxcontrib-htmlhelp==2.0.0
      - sphinxcontrib-jsmath==1.0.1
      - sphinxcontrib-qthelp==1.0.3
      - sphinxcontrib-serializinghtml==1.1.5
      - sqlparse==0.4.4
      - tomli==1.2.3
      - urllib3==1.26.20
prefix: /opt/conda/envs/ring

tests/test_key.py::test_classmethod_key
tests/test_key.py::test_provider_keys[format_key] tests/test_key.py::test_provider_keys[callable_key] tests/test_key.py::test_key_build[format_key] tests/test_key.py::test_key_build[callable_key] tests/test_key.py::test_key_repr[format_key] tests/test_key.py::test_key_repr[callable_key] tests/test_key.py::test_callable_key tests/test_key.py::test_unexisting_ring_key tests/test_key.py::test_singleton[None] tests/test_key.py::test_singleton[v1]
ring/wire.py
ring/wire.py