GithubHelp home page GithubHelp logo

Comments (4)

gaborbernat avatar gaborbernat commented on August 26, 2024

Feel free to put in a PR to fix this and we'll review it 👍

from retype.

Findus23 avatar Findus23 commented on August 26, 2024

Hi,

Many thanks for the quick response!

I will look into if I can fix it easy and create a PR, but I won't promise too much as I am possibly not familiar with python enough for this.

Honestly, this isn't even such an important feature, it would just be nice to have for my use case and I wanted to create an issue so that future users can immediately that this doesn't work yet instead of trying it out needlessly.

from retype.

Findus23 avatar Findus23 commented on August 26, 2024

Definitely not a proper solution and therefore I won't create a PR, but this works around the issue:

Patch:

diff --git a/src/retype/__init__.py b/src/retype/__init__.py
index 927d64f..adaad2a 100644
--- a/src/retype/__init__.py
+++ b/src/retype/__init__.py
@@ -238,6 +238,9 @@ def _r_functiondef(fun, node, flags):
         and node.parent.type == syms.classdef
         and "staticmethod" not in pyi_method_decorators
     )
+    if len(pyi_decorators) > 0 and ".setter" in pyi_decorators[0]:
+        print("skip setter")
+        return []
     args, returns = get_function_signature(fun, is_method=is_method)
     for child in flatten_some(node.children):
         decorators = None

(this is the diff of the full solution: https://github.com/ambv/retype/compare/master...Findus23:skip-setters?expand=1)
Output:

from typing import Any
class Testclass:
    value: Any = None

    @property
    def someprop(self) -> Any:
        return self.value

    @someprop.setter
    def someprop(self, value):
        self.value = value

And by adding a similar check for overload one can also work around #20

from retype.

gaborbernat avatar gaborbernat commented on August 26, 2024

This project is being retired and archived, so we'll no longer address this.

from retype.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.