Comments (4)
Feel free to put in a PR to fix this and we'll review it 👍
from retype.
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.
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.
This project is being retired and archived, so we'll no longer address this.
from retype.
Related Issues (15)
- lib2to3_parse assumes that the ParseError will always refer to an existing line HOT 1
- track line numbers between sources and target HOT 1
- allow ignoring folders during rewrite HOT 1
- retype doesn't check source encodings before parsing HOT 1
- Support overloaded definitions. HOT 1
- Class not found in source with @type_check_only HOT 3
- retype does not seem to handle `Callable` correctly
- single and double quotes in literals not handled correctly
- Redefining aliases that use typing module fails
- Mermaid diagram svg sizing issues - fixed height HOT 1
- Information: is there any public Python API? HOT 1
- Checkboxes in readme render as raw HTML on PyPI HOT 1
- quote forward references HOT 3
- Incompatible existing annotations when referencing classes in other modules HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from retype.